Thread: [Jsxe-cvs] SF.net SVN: jsxe: [892] trunk/jsxe
Status: Inactive
Brought to you by:
ian_lewis
|
From: <ian...@us...> - 2006-06-01 04:22:02
|
Revision: 892 Author: ian_lewis Date: 2006-05-31 21:21:50 -0700 (Wed, 31 May 2006) ViewCVS: http://svn.sourceforge.net/jsxe/?rev=892&view=rev Log Message: ----------- Plugins now implement EBListener and are added to the EditBus Modified Paths: -------------- trunk/jsxe/Changelog trunk/jsxe/src/net/sourceforge/jsxe/ActionPlugin.java trunk/jsxe/src/net/sourceforge/jsxe/jsXe.java Modified: trunk/jsxe/Changelog =================================================================== --- trunk/jsxe/Changelog 2006-05-31 22:27:12 UTC (rev 891) +++ trunk/jsxe/Changelog 2006-06-01 04:21:50 UTC (rev 892) @@ -1,3 +1,8 @@ +05/31/2006 Ian Lewis <Ian...@me...> + + * All plugins now implement EBListener and are added to the EditBus + * Updated the use of EditBus messages + 05/24/2006 Ian Lewis <Ian...@me...> * Updated the minimum version of xerces needed to run jsXe to 2.8. Modified: trunk/jsxe/src/net/sourceforge/jsxe/ActionPlugin.java =================================================================== --- trunk/jsxe/src/net/sourceforge/jsxe/ActionPlugin.java 2006-05-31 22:27:12 UTC (rev 891) +++ trunk/jsxe/src/net/sourceforge/jsxe/ActionPlugin.java 2006-06-01 04:21:50 UTC (rev 892) @@ -57,7 +57,7 @@ * @since jsXe 0.3 beta * @version $Id$ */ -public abstract class ActionPlugin { +public abstract class ActionPlugin implements EBListener { //{{{ Private members private ActionSet m_actionSet; @@ -123,6 +123,9 @@ return m_actionSet; }//}}} + //{{{ handleMessage() + public void handleMessage(EBMessage message) {}//}}} + //{{{ Broken class public static class Broken extends ActionPlugin { Modified: trunk/jsxe/src/net/sourceforge/jsxe/jsXe.java =================================================================== --- trunk/jsxe/src/net/sourceforge/jsxe/jsXe.java 2006-05-31 22:27:12 UTC (rev 891) +++ trunk/jsxe/src/net/sourceforge/jsxe/jsXe.java 2006-06-01 04:21:50 UTC (rev 892) @@ -284,6 +284,9 @@ } addActionSet(plugin.getActionSet()); + + //add the plugin to the editbus + EditBus.addToBus(plugin); } progressScreen.updateSplashScreenDialog(60); //}}} This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
|
From: <ian...@us...> - 2006-06-06 21:53:30
|
Revision: 907 Author: ian_lewis Date: 2006-06-06 14:53:19 -0700 (Tue, 06 Jun 2006) ViewCVS: http://svn.sourceforge.net/jsxe/?rev=907&view=rev Log Message: ----------- Added a new document options dialog to handle settings on a per document basis. Updated the Global options dialog so that it doesn't include the per document options anymore. Modified Paths: -------------- trunk/jsxe/Changelog trunk/jsxe/messages/messages.en trunk/jsxe/src/net/sourceforge/jsxe/action/ToolsOptionsAction.java trunk/jsxe/src/net/sourceforge/jsxe/gui/DirtyFilesDialog.java trunk/jsxe/src/net/sourceforge/jsxe/gui/EnhancedDialog.java trunk/jsxe/src/net/sourceforge/jsxe/gui/GlobalOptionsDialog.java trunk/jsxe/src/net/sourceforge/jsxe/gui/TabbedView.java trunk/jsxe/src/net/sourceforge/jsxe/properties Modified: trunk/jsxe/Changelog =================================================================== --- trunk/jsxe/Changelog 2006-06-06 19:57:21 UTC (rev 906) +++ trunk/jsxe/Changelog 2006-06-06 21:53:19 UTC (rev 907) @@ -1,3 +1,13 @@ +06/06/2006 Ian Lewis <Ian...@me...> + + * Added a new Document Options Dialog which handles settings on a per + document basis. + * Updated the Global Options so that they don't include the per document + options anymore. + * Updated the DirtyFilesDialog so that it selects the first entry by + default. + * Updated EnhancedDialogs to be resizable by default. + 05/31/2006 Ian Lewis <Ian...@me...> * All plugins now implement EBListener and are added to the EditBus Modified: trunk/jsxe/messages/messages.en =================================================================== --- trunk/jsxe/messages/messages.en 2006-06-06 19:57:21 UTC (rev 906) +++ trunk/jsxe/messages/messages.en 2006-06-06 21:53:19 UTC (rev 907) @@ -63,7 +63,11 @@ Global.Options.network-cache=Ask first, then cache remote files Global.Options.network-always=Always download without asking Global.Options.network=DTD and schema downloading: +#}}} + +#{{{ Document Options Document.Options.Title=XML Document Options +Document.Options.Message=This dialog changes settings for the current\n document only. To change settings on an\n editor-wide basis, see the\n Tools->Global Options dialog box. Document.Options.Line.Separator=Line Separator: Document.Options.Encoding=Encoding: Document.Options.Encoding.ToolTip=The encoding that jsXe uses to write the file. @@ -99,7 +103,8 @@ File.Exit=Exit #}}} -Tools.Options=Options... +Tools.Options=Global Options... +Tools.Document.Options=Document Options... Tools.Plugin=Plugin Manager... Tools.ValidationErrors=Validation Errors... Plugin.Manager.Title=Plugin Manager Modified: trunk/jsxe/src/net/sourceforge/jsxe/action/ToolsOptionsAction.java =================================================================== --- trunk/jsxe/src/net/sourceforge/jsxe/action/ToolsOptionsAction.java 2006-06-06 19:57:21 UTC (rev 906) +++ trunk/jsxe/src/net/sourceforge/jsxe/action/ToolsOptionsAction.java 2006-06-06 21:53:19 UTC (rev 907) @@ -64,7 +64,7 @@ public ToolsOptionsAction(TabbedView parent) { //putValue(Action.NAME, "Options..."); putValue(Action.NAME, Messages.getMessage("Tools.Options")); - putValue(Action.MNEMONIC_KEY, new Integer(KeyStroke.getKeyStroke("O").getKeyCode())); + putValue(Action.MNEMONIC_KEY, new Integer(KeyStroke.getKeyStroke("G").getKeyCode())); view = parent; }//}}} Modified: trunk/jsxe/src/net/sourceforge/jsxe/gui/DirtyFilesDialog.java =================================================================== --- trunk/jsxe/src/net/sourceforge/jsxe/gui/DirtyFilesDialog.java 2006-06-06 19:57:21 UTC (rev 906) +++ trunk/jsxe/src/net/sourceforge/jsxe/gui/DirtyFilesDialog.java 2006-06-06 21:53:19 UTC (rev 907) @@ -196,7 +196,7 @@ buttons.add(selectAllJButton); saveSelectedJButton.setText(Messages.getMessage("DirtyFilesDialog.Button.SaveSelected.Title")); - saveSelectedJButton .addActionListener(new ActionListener() { + saveSelectedJButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { saveSelectedJButtonActionPerformed(); } Modified: trunk/jsxe/src/net/sourceforge/jsxe/gui/EnhancedDialog.java =================================================================== --- trunk/jsxe/src/net/sourceforge/jsxe/gui/EnhancedDialog.java 2006-06-06 19:57:21 UTC (rev 906) +++ trunk/jsxe/src/net/sourceforge/jsxe/gui/EnhancedDialog.java 2006-06-06 21:53:19 UTC (rev 907) @@ -157,8 +157,21 @@ jsXe.setIntegerProperty(name + ".height",bounds.height); } //}}} - public abstract void ok(); - public abstract void cancel(); + //{{{ ok() + /** + * The method that is called when enter is pressed when viewing the dialog. + * In options dialogs this would corresponding to when the OK button is + * pressed. + */ + public abstract void ok();//}}} + + //{{{ cancel() + /** + * The method that is called when escape is pressed when viewing the dialog. + * In options dialogs this would corresponding to when the Cancel button is + * pressed. + */ + public abstract void cancel();//}}} //{{{ Private members Modified: trunk/jsxe/src/net/sourceforge/jsxe/gui/GlobalOptionsDialog.java =================================================================== --- trunk/jsxe/src/net/sourceforge/jsxe/gui/GlobalOptionsDialog.java 2006-06-06 19:57:21 UTC (rev 906) +++ trunk/jsxe/src/net/sourceforge/jsxe/gui/GlobalOptionsDialog.java 2006-06-06 21:53:19 UTC (rev 907) @@ -78,10 +78,6 @@ } } - pane = buffer.getOptionsPanel(); - if (pane != null) { - addOptionPane(pane); - } addOptionGroup(m_defaultGroup, rootGroup); return paneTreeModel; Modified: trunk/jsxe/src/net/sourceforge/jsxe/gui/TabbedView.java =================================================================== --- trunk/jsxe/src/net/sourceforge/jsxe/gui/TabbedView.java 2006-06-06 19:57:21 UTC (rev 906) +++ trunk/jsxe/src/net/sourceforge/jsxe/gui/TabbedView.java 2006-06-06 21:53:19 UTC (rev 907) @@ -442,6 +442,7 @@ set.addAction("close-file", new FileCloseAction(this)); set.addAction("close-all", new FileCloseAllAction(this)); set.addAction("exit", new FileExitAction(this)); + set.addAction("document-options", new DocumentOptionsAction(this)); set.addAction("general-options", new ToolsOptionsAction(this)); set.addAction("plugin-manager", new ToolsPluginManagerAction(this)); set.addAction("about-jsxe", new jsxeAboutDialog(this)); @@ -528,6 +529,8 @@ //{{{ Create Tools Menu m_toolsMenu = new JMenu(Messages.getMessage("Tools.Menu")); m_toolsMenu.setMnemonic('T'); + menuItem = new JMenuItem(jsXe.getAction("document-options")); + m_toolsMenu.add(menuItem); menuItem = new JMenuItem(jsXe.getAction("general-options")); m_toolsMenu.add(menuItem); menuItem = new JMenuItem(jsXe.getAction("plugin-manager")); Modified: trunk/jsxe/src/net/sourceforge/jsxe/properties =================================================================== --- trunk/jsxe/src/net/sourceforge/jsxe/properties 2006-06-06 19:57:21 UTC (rev 906) +++ trunk/jsxe/src/net/sourceforge/jsxe/properties 2006-06-06 21:53:19 UTC (rev 907) @@ -13,26 +13,31 @@ xml.cache=true #{{{ Plugin Manager Default Dimensions -pluginmgr.x=100 -pluginmgr.y=100 +#pluginmgr.x=100 +#pluginmgr.y=100 pluginmgr.height=300 pluginmgr.width=400 #}}} #{{{ Dirty Files Dialog Default Dimensions -dirtyfiles.x=100 -dirtyfiles.y=100 +#dirtyfiles.x=100 +#dirtyfiles.y=100 dirtyfiles.height=300 dirtyfiles.width=500 #}}} #{{{ Activity Log default dimensions -activitylog.x=100 -activitylog.y=100 -activitylog.height=300 -activitylog.width=300 +#activitylog.x=100 +#activitylog.y=100 +activitylog.height=400 +activitylog.width=500 #}}} +#{{{ Document Options Dialog default dimensions +Document.Options.width=300 +Document.Options.height=400 +#}}} + #{{{ Metal control and menu font metal.primary.font=Dialog metal.primary.fontsize=12 This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
|
From: <ian...@us...> - 2006-06-07 03:42:26
|
Revision: 909 Author: ian_lewis Date: 2006-06-06 20:42:19 -0700 (Tue, 06 Jun 2006) ViewCVS: http://svn.sourceforge.net/jsxe/?rev=909&view=rev Log Message: ----------- Updated the file dialog to use localized messages in the title Modified Paths: -------------- trunk/jsxe/Changelog trunk/jsxe/messages/messages.en trunk/jsxe/src/net/sourceforge/jsxe/gui/jsxeFileDialog.java Modified: trunk/jsxe/Changelog =================================================================== --- trunk/jsxe/Changelog 2006-06-07 03:32:15 UTC (rev 908) +++ trunk/jsxe/Changelog 2006-06-07 03:42:19 UTC (rev 909) @@ -7,6 +7,7 @@ * Updated the DirtyFilesDialog so that it selects the first entry by default. * Updated EnhancedDialogs to be resizable by default. + * Updated the file dialog to use localized messages in the title 05/31/2006 Ian Lewis <Ian...@me...> Modified: trunk/jsxe/messages/messages.en =================================================================== --- trunk/jsxe/messages/messages.en 2006-06-07 03:32:15 UTC (rev 908) +++ trunk/jsxe/messages/messages.en 2006-06-07 03:42:19 UTC (rev 909) @@ -8,6 +8,9 @@ common.ok=OK common.cancel=Cancel +common.open=Open +common.save=Save +common.save.as=Save As common.close=Close common.apply=Apply common.more=More Modified: trunk/jsxe/src/net/sourceforge/jsxe/gui/jsxeFileDialog.java =================================================================== --- trunk/jsxe/src/net/sourceforge/jsxe/gui/jsxeFileDialog.java 2006-06-07 03:32:15 UTC (rev 908) +++ trunk/jsxe/src/net/sourceforge/jsxe/gui/jsxeFileDialog.java 2006-06-07 03:42:19 UTC (rev 909) @@ -76,14 +76,14 @@ //{{{ showOpenDialog() public int showOpenDialog(Component parent) { - setDialogTitle("Open"); + setDialogTitle(Messages.getMessage("common.open")); return super.showOpenDialog(parent); }//}}} //{{{ showSaveDialog() public int showSaveDialog(Component parent) { - setDialogTitle("Save As"); + setDialogTitle(Messages.getMessage("common.save.as")); return super.showSaveDialog(parent); }//}}} This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
|
From: <ian...@us...> - 2006-06-07 05:46:07
|
Revision: 910 Author: ian_lewis Date: 2006-06-06 22:45:54 -0700 (Tue, 06 Jun 2006) ViewCVS: http://svn.sourceforge.net/jsxe/?rev=910&view=rev Log Message: ----------- Updated the document options to use abstract classes to lay out the dialog. OptionsPanel is now deprecated in favor of using the OptionPane and AbstractOptionPane classes. Modified Paths: -------------- trunk/jsxe/Changelog trunk/jsxe/messages/messages.en trunk/jsxe/src/net/sourceforge/jsxe/CatalogManager.java trunk/jsxe/src/net/sourceforge/jsxe/DocumentBuffer.java trunk/jsxe/src/net/sourceforge/jsxe/gui/DocumentOptionsDialog.java trunk/jsxe/src/net/sourceforge/jsxe/gui/OptionsPanel.java trunk/jsxe/src/net/sourceforge/jsxe/options/OptionPane.java Added Paths: ----------- trunk/jsxe/src/net/sourceforge/jsxe/gui/GridPanel.java Modified: trunk/jsxe/Changelog =================================================================== --- trunk/jsxe/Changelog 2006-06-07 03:42:19 UTC (rev 909) +++ trunk/jsxe/Changelog 2006-06-07 05:45:54 UTC (rev 910) @@ -1,3 +1,9 @@ +06/07/2006 Ian Lewis <Ian...@me...> + + * Updated the document options to use abstract classes to lay out the + dialog. OptionsPanel is now deprecated in favor of using the OptionPane + and AbstractOptionPane classes. + 06/06/2006 Ian Lewis <Ian...@me...> * Added a new Document Options Dialog which handles settings on a per Modified: trunk/jsxe/messages/messages.en =================================================================== --- trunk/jsxe/messages/messages.en 2006-06-07 03:42:19 UTC (rev 909) +++ trunk/jsxe/messages/messages.en 2006-06-07 05:45:54 UTC (rev 910) @@ -72,6 +72,7 @@ Document.Options.Title=XML Document Options Document.Options.Message=This dialog changes settings for the current\n document only. To change settings on an\n editor-wide basis, see the\n Tools->Global Options dialog box. Document.Options.Line.Separator=Line Separator: +Document.Options.Line.Separator.ToolTip=The line separator. Usually you'll pick the line separator used by your operating system. Document.Options.Encoding=Encoding: Document.Options.Encoding.ToolTip=The encoding that jsXe uses to write the file. Document.Options.Indent.Width=Indent width: Modified: trunk/jsxe/src/net/sourceforge/jsxe/CatalogManager.java =================================================================== --- trunk/jsxe/src/net/sourceforge/jsxe/CatalogManager.java 2006-06-07 03:42:19 UTC (rev 909) +++ trunk/jsxe/src/net/sourceforge/jsxe/CatalogManager.java 2006-06-07 05:45:54 UTC (rev 910) @@ -4,8 +4,8 @@ :folding=explicit:collapseFolds=1: * Copyright (C) 2001, 2003 Slava Pestov - * Portions copyright (C) 2002 Chris Stevenson - * Portions copyright (C) 2005 Ian Lewis (Ian...@me...) + * Portions Copyright (C) 2002 Chris Stevenson + * Portions Copyright (C) 2005 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 Modified: trunk/jsxe/src/net/sourceforge/jsxe/DocumentBuffer.java =================================================================== --- trunk/jsxe/src/net/sourceforge/jsxe/DocumentBuffer.java 2006-06-07 03:42:19 UTC (rev 909) +++ trunk/jsxe/src/net/sourceforge/jsxe/DocumentBuffer.java 2006-06-07 05:45:54 UTC (rev 910) @@ -35,6 +35,7 @@ import net.sourceforge.jsxe.dom.XMLDocument; import net.sourceforge.jsxe.dom.XMLDocumentListener; import net.sourceforge.jsxe.dom.AdapterNode; +import net.sourceforge.jsxe.options.AbstractOptionPane; import net.sourceforge.jsxe.options.OptionPane; import net.sourceforge.jsxe.gui.*; import net.sourceforge.jsxe.util.Log; @@ -479,14 +480,14 @@ return equalsOnDisk(buffer.getFile()); }//}}} - //{{{ getOptionsPanel() + //{{{ getOptionPane() /** * Gets the pane for editing options for this DocumentBuffer. * @return the option pane specific to this DocumentBuffer */ - public OptionsPanel getOptionsPanel() { - return new DocumentBufferOptionsPanel(); + public OptionPane getOptionPane() { + return new DocumentBufferOptionPane(); }//}}} //{{{ fireStructureChanged() @@ -533,31 +534,27 @@ return "Untitled-" + Integer.toString(untitledNo+1); }//}}} - //{{{ DocumentBufferOptionsPane class + //{{{ DocumentBufferOptionPane class - private class DocumentBufferOptionsPanel extends OptionsPanel { + private class DocumentBufferOptionPane extends AbstractOptionPane { //{{{ DocumentBufferOptionsPanel() + public DocumentBufferOptionPane() { + super("documentbuffer"); + }//}}} - public DocumentBufferOptionsPanel() { + //{{{ _init() + protected void _init() { - GridBagLayout layout = new GridBagLayout(); - GridBagConstraints constraints = new GridBagConstraints(); - - //the grid y coordinate. - int gridY = 0; - - setLayout(layout); - - //Set up line separator combo-box + //{{{ line separator m_m_lineSeparators.put("Unix (\\n)", "\n"); m_m_lineSeparators.put("DOS/Windows (\\r\\n)", "\r\n"); m_m_lineSeparators.put("MacOS (\\r)", "\r"); - JLabel lineSeparatorLabel = new JLabel(Messages.getMessage("Document.Options.Line.Separator")); - lineSeparatorLabel.setToolTipText(Messages.getMessage("Document.Options.Line.Separator.ToolTip")); + // JLabel lineSeparatorLabel = new JLabel(Messages.getMessage("Document.Options.Line.Separator")); + // lineSeparatorLabel.setToolTipText(Messages.getMessage("Document.Options.Line.Separator.ToolTip")); m_m_lineSeparatorComboBox = new JComboBox(new Vector(m_m_lineSeparators.keySet())); m_m_lineSeparatorComboBox.setName("LineSeparatorComboBox"); - m_m_lineSeparatorComboBox.setToolTipText(Messages.getMessage("Document.Options.Line.Separator.ToolTip")); + // m_m_lineSeparatorComboBox.setToolTipText(Messages.getMessage("Document.Options.Line.Separator.ToolTip")); String lineSep = getProperty(LINE_SEPARATOR); if (lineSep.equals("\r\n")) { @@ -567,15 +564,21 @@ } else { m_m_lineSeparatorComboBox.setSelectedItem("Unix (\\n)"); } + + addComponent(Messages.getMessage("Document.Options.Line.Separator"), + m_m_lineSeparatorComboBox, + Messages.getMessage("Document.Options.Line.Separator.ToolTip")); - //set up the encoding combo-box. + //}}} + + //{{{ encoding String[] encodings = MiscUtilities.getSupportedEncodings(); - JLabel encodingLabel = new JLabel(Messages.getMessage("Document.Options.Encoding")); - encodingLabel.setToolTipText(Messages.getMessage("Document.Options.Encoding.ToolTip")); + // JLabel encodingLabel = new JLabel(Messages.getMessage("Document.Options.Encoding")); + // encodingLabel.setToolTipText(Messages.getMessage("Document.Options.Encoding.ToolTip")); encodingComboBox = new JComboBox(encodings); encodingComboBox.setName("EncodingComboBox"); encodingComboBox.setEditable(false); - encodingComboBox.setToolTipText(Messages.getMessage("Document.Options.Encoding.ToolTip")); + // encodingComboBox.setToolTipText(Messages.getMessage("Document.Options.Encoding.ToolTip")); for (int i=0; i<encodings.length; i++) { if (getProperty(ENCODING).equals(encodings[i])) { @@ -583,8 +586,15 @@ } } - JLabel indentLabel = new JLabel(Messages.getMessage("Document.Options.Indent.Width")); - indentLabel.setToolTipText(Messages.getMessage("Document.Options.Indent.Width.ToolTip")); + addComponent(Messages.getMessage("Document.Options.Encoding"), + encodingComboBox, + Messages.getMessage("Document.Options.Encoding.ToolTip")); + + //}}} + + //{{{ indent width + // JLabel indentLabel = new JLabel(Messages.getMessage("Document.Options.Indent.Width")); + // indentLabel.setToolTipText(Messages.getMessage("Document.Options.Indent.Width.ToolTip")); Vector sizes = new Vector(3); sizes.add("2"); sizes.add("4"); @@ -593,169 +603,76 @@ indentComboBox.setName("IndentComboBox"); indentComboBox.setEditable(true); indentComboBox.setSelectedItem(getProperty(INDENT)); - indentComboBox.setToolTipText(Messages.getMessage("Document.Options.Indent.Width.ToolTip")); + // indentComboBox.setToolTipText(Messages.getMessage("Document.Options.Indent.Width.ToolTip")); + addComponent(Messages.getMessage("Document.Options.Indent.Width"), + indentComboBox, + Messages.getMessage("Document.Options.Indent.Width.ToolTip")); - // boolean whitespace = Boolean.valueOf(m_document.getProperty(XMLDocument.WS_IN_ELEMENT_CONTENT, "true")).booleanValue(); + //}}} + + //{{{ format output boolean formatOutput = Boolean.valueOf(getProperty(XMLDocument.FORMAT_XML, "false")).booleanValue(); + formatCheckBox = new JCheckBox(Messages.getMessage("Document.Options.Format.XML"), formatOutput); - // whitespaceCheckBox = new JCheckBox("Whitespace in element content", whitespace); - formatCheckBox = new JCheckBox(Messages.getMessage("Document.Options.Format.XML"), formatOutput); + addComponent(formatCheckBox, Messages.getMessage("Document.Options.Format.XML.ToolTip")); + //}}} - // whitespaceCheckBox.addChangeListener(new WhiteSpaceChangeListener()); - + //{{{ validate boolean validating = Boolean.valueOf(getProperty(XMLDocument.IS_VALIDATING, "false")).booleanValue(); m_m_validatingCheckBox = new JCheckBox(Messages.getMessage("Document.Options.Validate"), validating); - // formatCheckBox.setEnabled(!whitespace); + addComponent(m_m_validatingCheckBox, Messages.getMessage("Document.Options.Validate.ToolTip")); + //}}} - constraints.gridy = gridY; - constraints.gridx = 0; - constraints.gridheight = 1; - constraints.gridwidth = 1; - constraints.weightx = 1.0f; - constraints.fill = GridBagConstraints.BOTH; - constraints.insets = new Insets(1,0,1,0); - - layout.setConstraints(lineSeparatorLabel, constraints); - add(lineSeparatorLabel); - - constraints.gridy = gridY++; - constraints.gridx = 1; - constraints.gridheight = 1; - constraints.gridwidth = 1; - constraints.weightx = 1.0f; - constraints.fill = GridBagConstraints.BOTH; - constraints.insets = new Insets(1,0,1,0); - - layout.setConstraints(m_m_lineSeparatorComboBox, constraints); - add(m_m_lineSeparatorComboBox); - - constraints.gridy = gridY; - constraints.gridx = 0; - constraints.gridheight = 1; - constraints.gridwidth = 1; - constraints.weightx = 1.0f; - constraints.fill = GridBagConstraints.BOTH; - constraints.insets = new Insets(1,0,1,0); - - layout.setConstraints(encodingLabel, constraints); - add(encodingLabel); - - constraints.gridy = gridY++; - constraints.gridx = 1; - constraints.gridheight = 1; - constraints.gridwidth = 1; - constraints.weightx = 1.0f; - constraints.fill = GridBagConstraints.BOTH; - constraints.insets = new Insets(1,0,1,0); - - layout.setConstraints(encodingComboBox, constraints); - add(encodingComboBox); - - constraints.gridy = gridY; - constraints.gridx = 0; - constraints.gridheight = 1; - constraints.gridwidth = 1; - constraints.weightx = 1.0f; - constraints.fill = GridBagConstraints.BOTH; - constraints.insets = new Insets(1,0,1,0); - - layout.setConstraints(indentLabel, constraints); - add(indentLabel); - - constraints.gridy = gridY++; - constraints.gridx = 1; - constraints.gridheight = 1; - constraints.gridwidth = 1; - constraints.weightx = 1.0f; - constraints.fill = GridBagConstraints.BOTH; - constraints.insets = new Insets(1,0,1,0); - - layout.setConstraints(indentComboBox, constraints); - add(indentComboBox); - - // constraints.gridy = gridY++; - // constraints.gridx = 0; - // constraints.gridheight = 1; - // constraints.gridwidth = GridBagConstraints.REMAINDER; - // constraints.weightx = 0.0f; - // constraints.fill = GridBagConstraints.BOTH; - // constraints.insets = new Insets(1,0,1,0); - - // layout.setConstraints(whitespaceCheckBox, constraints); - // add(whitespaceCheckBox); - - constraints.gridy = gridY++; - constraints.gridx = 0; - constraints.gridheight = 1; - constraints.gridwidth = GridBagConstraints.REMAINDER; - constraints.weightx = 0.0f; - constraints.fill = GridBagConstraints.BOTH; - constraints.insets = new Insets(1,0,1,0); - - layout.setConstraints(formatCheckBox, constraints); - add(formatCheckBox); - formatCheckBox.setToolTipText(Messages.getMessage("Document.Options.Format.XML.ToolTip")); - - constraints.gridy = gridY++; - constraints.gridx = 0; - constraints.gridheight = 1; - constraints.gridwidth = GridBagConstraints.REMAINDER; - constraints.weightx = 0.0f; - constraints.fill = GridBagConstraints.BOTH; - constraints.insets = new Insets(1,0,1,0); - - layout.setConstraints(m_m_validatingCheckBox, constraints); - add(m_m_validatingCheckBox); - m_m_validatingCheckBox.setToolTipText(Messages.getMessage("Document.Options.Validate.ToolTip")); - + //{{{ soft tabs boolean softTabs = Boolean.valueOf(getProperty(XMLDocument.IS_USING_SOFT_TABS, "false")).booleanValue(); - m_m_softTabsCheckBox = new JCheckBox(Messages.getMessage("Document.Options.Soft.Tabs"), softTabs); - constraints.gridy = gridY++; - constraints.gridx = 0; - constraints.gridheight = 1; - constraints.gridwidth = GridBagConstraints.REMAINDER; - constraints.weightx = 0.0f; - constraints.fill = GridBagConstraints.BOTH; - constraints.insets = new Insets(1,0,1,0); + addComponent(m_m_softTabsCheckBox, Messages.getMessage("Document.Options.Soft.Tabs.ToolTip")); + ////}}} - layout.setConstraints(m_m_softTabsCheckBox, constraints); - add(m_m_softTabsCheckBox); - m_m_softTabsCheckBox.setToolTipText(Messages.getMessage("Document.Options.Soft.Tabs.ToolTip")); - }//}}} - //{{{ save() - - public void save() { + //{{{ _save() + protected void _save() { + //{{{ line separator if (!(m_m_lineSeparators.get(m_m_lineSeparatorComboBox.getSelectedItem()).toString().equals(getProperty(LINE_SEPARATOR)))) { setDirty(true); setProperty(LINE_SEPARATOR, m_m_lineSeparators.get(m_m_lineSeparatorComboBox.getSelectedItem()).toString()); - } + }//}}} + //{{{ formatting if (!String.valueOf(formatCheckBox.isSelected()).equals(getProperty(XMLDocument.FORMAT_XML))) { setDirty(true); setProperty(XMLDocument.FORMAT_XML, String.valueOf(formatCheckBox.isSelected())); } + //}}} + + //{{{ soft tabs if (!String.valueOf(m_m_softTabsCheckBox.isSelected()).equals(getProperty(XMLDocument.IS_USING_SOFT_TABS))) { setDirty(true); setProperty(XMLDocument.IS_USING_SOFT_TABS, String.valueOf(m_m_softTabsCheckBox.isSelected())); } + //}}} + + //{{{ validating + if (!String.valueOf(m_m_validatingCheckBox.isSelected()).equals(getProperty(XMLDocument.IS_VALIDATING))) { setProperty(XMLDocument.IS_VALIDATING, String.valueOf(m_m_validatingCheckBox.isSelected())); } - // if (!String.valueOf(whitespaceCheckBox.isSelected()).equals(m_document.getProperty(XMLDocument.WS_IN_ELEMENT_CONTENT))) { - // setDirty(true); - // m_document.setProperty(XMLDocument.WS_IN_ELEMENT_CONTENT, String.valueOf(whitespaceCheckBox.isSelected())); - // } + //}}} + + //{{{ encoding + if (!encodingComboBox.getSelectedItem().toString().equals(getProperty(XMLDocument.ENCODING))) { setDirty(true); setProperty(XMLDocument.ENCODING, encodingComboBox.getSelectedItem().toString()); } + //}}} + //{{{ indent width + if (!getProperty(XMLDocument.INDENT).equals(indentComboBox.getSelectedItem().toString())) { try { //don't need to set dirty, no change to text @@ -771,38 +688,20 @@ //Bad input, don't save. } } + //}}} };//}}} //{{{ getName() - public String getName() { return "documentbuffer"; }//}}} //{{{ getTitle() - public String getTitle() { return Messages.getMessage("Document.Options.Title"); - };//}}} + }//}}} - // //{{{ WhiteSpaceChangeListener class - - // private class WhiteSpaceChangeListener implements ChangeListener { - - // //{{{ stateChanged() - - // public void stateChanged(ChangeEvent e) { - // boolean whitespace = whitespaceCheckBox.isSelected(); - // if (whitespace) { - // formatCheckBox.setSelected(false); - // } - // formatCheckBox.setEnabled(!whitespace); - // }//}}} - - // }//}}} - //{{{ Private members - private DocumentBuffer m_buffer; private JCheckBox m_m_softTabsCheckBox; private JComboBox encodingComboBox; Modified: trunk/jsxe/src/net/sourceforge/jsxe/gui/DocumentOptionsDialog.java =================================================================== --- trunk/jsxe/src/net/sourceforge/jsxe/gui/DocumentOptionsDialog.java 2006-06-07 03:42:19 UTC (rev 909) +++ trunk/jsxe/src/net/sourceforge/jsxe/gui/DocumentOptionsDialog.java 2006-06-07 05:45:54 UTC (rev 910) @@ -3,7 +3,7 @@ :tabSize=4:indentSize=4:noTabs=true: :folding=explicit:collapseFolds=1: -Copyright (C) 2005 Trish Harnett (tri...@me...) +Copyright (C) 2005 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 @@ -28,6 +28,7 @@ //{{{ jsXe imports import net.sourceforge.jsxe.DocumentBuffer; +import net.sourceforge.jsxe.options.OptionPane; import net.sourceforge.jsxe.util.Log; //}}} @@ -60,17 +61,19 @@ super(parent, Messages.getMessage("Document.Options.Title"), true); m_view = parent; DocumentBuffer buffer = m_view.getDocumentBuffer(); - m_optionsPanel = buffer.getOptionsPanel(); + m_optionPane = buffer.getOptionPane(); + m_optionPane.init(); + JPanel content = new JPanel(new BorderLayout(12,12)); content.setBorder(new EmptyBorder(12,12,12,12)); setContentPane(content); - JPanel panel = new JPanel(new BorderLayout()); + GridPanel panel = new GridPanel(); - panel.add(createMultilineLabel(Messages.getMessage("Document.Options.Message")), BorderLayout.NORTH); - panel.add(new JSeparator(JSeparator.HORIZONTAL), BorderLayout.CENTER); - panel.add(m_optionsPanel, BorderLayout.SOUTH); + panel.addComponent(createMultilineLabel(Messages.getMessage("Document.Options.Message"))); + panel.addSeparator(); + panel.addComponent(m_optionPane.getComponent()); getContentPane().add(panel, BorderLayout.CENTER); @@ -104,7 +107,7 @@ //{{{ ok() public void ok() { - m_optionsPanel.save(); + m_optionPane.save(); cancel(); }//}}} @@ -154,6 +157,6 @@ /** * The document options panel for the current document */ - private OptionsPanel m_optionsPanel; + private OptionPane m_optionPane; //}}} } Added: trunk/jsxe/src/net/sourceforge/jsxe/gui/GridPanel.java =================================================================== --- trunk/jsxe/src/net/sourceforge/jsxe/gui/GridPanel.java (rev 0) +++ trunk/jsxe/src/net/sourceforge/jsxe/gui/GridPanel.java 2006-06-07 05:45:54 UTC (rev 910) @@ -0,0 +1,195 @@ +/* +AbstractOptionPane.java +:tabSize=4:indentSize=4:noTabs=true: +:folding=explicit:collapseFolds=1: + +Copyright (C) 1998, 1999, 2000, 2001, 2002 Slava Pestov +Portions Copyright (C) 2005 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 net.sourceforge.jsxe.gui; + +//{{{ Imports +import javax.swing.border.EmptyBorder; +import javax.swing.*; +import java.awt.*; +//}}} + +/** + * A convenient class for laying out components in a form or dialog. + * + * It is derived from Java's <code>JPanel</code> class and uses a + * <code>GridBagLayout</code> object for component management. Since + * <code>GridBagLayout</code> can be a bit cumbersome to use, this class + * contains shortcut methods to simplify layout: + * + * <ul> + * <li>{@link #addComponent(Component)}</li> + * <li>{@link #addComponent(Component,int)}</li> + * <li>{@link #addSeparator()}</li> + * <li>{@link #addSeparator(String)}</li> + * </ul> + * + * @ + * @author Slava Pestov + * @author John Gellene (API documentation) + * @author Ian Lewis (<a href="mailto:Ian...@me...">Ian...@me...</a>) + * @version $Id$ + * @since jsXe 0.5 pre1 + */ +public class GridPanel extends JPanel { + + //{{{ GridPanel constructor + /** + * Creates a new panel. + */ + public GridPanel() { + setLayout(gridBag = new GridBagLayout()); + } //}}} + + //{{{ getComponent() method + /** + * Returns the component that should be displayed for this option pane. + * Because this class extends Component, it simply returns "this". + */ + public Component getComponent() { + return this; + } //}}} + + //{{{ addComponent() method + /** + * Adds a component to the option pane. Components are + * added in a vertical fashion, one per row. + * @param comp The component + */ + public void addComponent(Component comp) { + GridBagConstraints cons = new GridBagConstraints(); + cons.gridy = y++; + cons.gridheight = 1; + cons.gridwidth = cons.REMAINDER; + cons.fill = GridBagConstraints.NONE; + cons.anchor = GridBagConstraints.WEST; + cons.weightx = 1.0f; + cons.insets = new Insets(1,0,1,0); + + gridBag.setConstraints(comp,cons); + add(comp); + } //}}} + + //{{{ addComponent() method + /** + * Adds a component to the option pane. Components are + * added in a vertical fashion, one per row. + * @param comp The component + * @param fill Fill parameter to GridBagConstraints + */ + public void addComponent(Component comp, int fill) { + GridBagConstraints cons = new GridBagConstraints(); + cons.gridy = y++; + cons.gridheight = 1; + cons.gridwidth = cons.REMAINDER; + cons.fill = fill; + cons.anchor = GridBagConstraints.WEST; + cons.weightx = 1.0f; + cons.insets = new Insets(1,0,1,0); + + gridBag.setConstraints(comp,cons); + add(comp); + } //}}} + + //{{{ addSeparator() method + /** + * Adds a separator component. + */ + public void addSeparator() { + addComponent(Box.createVerticalStrut(6)); + + JSeparator sep = new JSeparator(JSeparator.HORIZONTAL); + + GridBagConstraints cons = new GridBagConstraints(); + cons.gridy = y++; + cons.gridheight = 1; + cons.gridwidth = cons.REMAINDER; + cons.fill = GridBagConstraints.BOTH; + cons.anchor = GridBagConstraints.WEST; + cons.weightx = 1.0f; + //cons.insets = new Insets(1,0,1,0); + + gridBag.setConstraints(sep,cons); + add(sep); + + addComponent(Box.createVerticalStrut(6)); + } //}}} + + //{{{ addSeparator() method + /** + * Adds a separator component. + * @param label The separator label property + */ + public void addSeparator(String label) { + if (y != 0) { + addComponent(Box.createVerticalStrut(6)); + } + + Box box = new Box(BoxLayout.X_AXIS); + Box box2 = new Box(BoxLayout.Y_AXIS); + box2.add(Box.createGlue()); + box2.add(new JSeparator(JSeparator.HORIZONTAL)); + box2.add(Box.createGlue()); + box.add(box2); + JLabel l = new JLabel(label); + l.setMaximumSize(l.getPreferredSize()); + box.add(l); + Box box3 = new Box(BoxLayout.Y_AXIS); + box3.add(Box.createGlue()); + box3.add(new JSeparator(JSeparator.HORIZONTAL)); + box3.add(Box.createGlue()); + box.add(box3); + + GridBagConstraints cons = new GridBagConstraints(); + cons.gridy = y++; + cons.gridheight = 1; + cons.gridwidth = cons.REMAINDER; + cons.fill = GridBagConstraints.BOTH; + cons.anchor = GridBagConstraints.WEST; + cons.weightx = 1.0f; + cons.insets = new Insets(1,0,1,0); + + gridBag.setConstraints(box,cons); + add(box); + } //}}} + + //{{{ Protected members + /** + * Has the option pane been initialized? + */ + protected boolean initialized; + + /** + * The layout manager. + */ + protected GridBagLayout gridBag; + + /** + * The number of components already added to the layout manager. + */ + protected int y; + //}}} + +} Modified: trunk/jsxe/src/net/sourceforge/jsxe/gui/OptionsPanel.java =================================================================== --- trunk/jsxe/src/net/sourceforge/jsxe/gui/OptionsPanel.java 2006-06-07 03:42:19 UTC (rev 909) +++ trunk/jsxe/src/net/sourceforge/jsxe/gui/OptionsPanel.java 2006-06-07 05:45:54 UTC (rev 910) @@ -47,6 +47,7 @@ * @author <a href="mailto:IanLewis at member dot fsf dot org">Ian Lewis</a> * @version $Id$ * @see OptionsDialog + * @deprecated implement OptionPane directly or use AbstractOptionPane */ public abstract class OptionsPanel extends JPanel implements OptionPane { Modified: trunk/jsxe/src/net/sourceforge/jsxe/options/OptionPane.java =================================================================== --- trunk/jsxe/src/net/sourceforge/jsxe/options/OptionPane.java 2006-06-07 03:42:19 UTC (rev 909) +++ trunk/jsxe/src/net/sourceforge/jsxe/options/OptionPane.java 2006-06-07 05:45:54 UTC (rev 910) @@ -34,8 +34,9 @@ * method. The label displayed in the option pane's tab is obtained from the * <code>getTitle()</code> method. * - * Note that you should extend the {@link net.sourceforge.jsxe.gui.OptionPanel} - * if creating an OptionPane for use with jsXe. + * Note that you may want to extend the + * {@link net.sourceforge.jsxe.options.AbstractOptionPane} if creating an + * OptionPane for use with jsXe. * * @see OptionGroup * @see net.sourceforge.jsxe.gui.OptionsDialog#addOptionPane(OptionPane) @@ -55,6 +56,9 @@ //}}} //{{{ getTitle() + /** + * Get the human readable title of the option pane + */ public String getTitle(); //}}} This was sent by the SourceForge.net collaborative development plat... [truncated message content] |
|
From: <ian...@us...> - 2006-06-07 06:07:55
|
Revision: 912 Author: ian_lewis Date: 2006-06-06 23:07:44 -0700 (Tue, 06 Jun 2006) ViewCVS: http://svn.sourceforge.net/jsxe/?rev=912&view=rev Log Message: ----------- Updated dialogs to use setVisible() instead of show() Modified Paths: -------------- trunk/jsxe/Changelog trunk/jsxe/src/net/sourceforge/jsxe/action/ActivityLogAction.java trunk/jsxe/src/net/sourceforge/jsxe/gui/OptionsDialog.java trunk/jsxe/src/net/sourceforge/jsxe/gui/PluginManagerDialog.java Modified: trunk/jsxe/Changelog =================================================================== --- trunk/jsxe/Changelog 2006-06-07 06:01:12 UTC (rev 911) +++ trunk/jsxe/Changelog 2006-06-07 06:07:44 UTC (rev 912) @@ -3,6 +3,7 @@ * Updated the document options to use abstract classes to lay out the dialog. OptionsPanel is now deprecated in favor of using the OptionPane and AbstractOptionPane classes. + * Updated dialogs to use setVisible() instead of show() 06/06/2006 Ian Lewis <Ian...@me...> Modified: trunk/jsxe/src/net/sourceforge/jsxe/action/ActivityLogAction.java =================================================================== --- trunk/jsxe/src/net/sourceforge/jsxe/action/ActivityLogAction.java 2006-06-07 06:01:12 UTC (rev 911) +++ trunk/jsxe/src/net/sourceforge/jsxe/action/ActivityLogAction.java 2006-06-07 06:07:44 UTC (rev 912) @@ -58,33 +58,27 @@ * @version $Id$ */ public class ActivityLogAction extends AbstractAction { - - // {{{ Public members + + // {{{ Private members private TabbedView view; - // private boolean activityLogUpdated = false; private ActivityLogDialog dialog = new ActivityLogDialog(view); //}}} - //{{{ ActivityLogAction - /** + //{{{ ActivityLogAction constructor + /** * @param TabbedView parent view containing the JSXE editor. * Constructor for the ActivityLogActionclass * @since jsXe 0.3pre15 */ public ActivityLogAction(TabbedView parent) { - putValue(Action.NAME, Messages.getMessage("ActivityLogDialog.Open")); + putValue(Action.NAME, Messages.getMessage("ActivityLogDialog.Open")); putValue(Action.MNEMONIC_KEY, new Integer(KeyStroke.getKeyStroke("L").getKeyCode())); view = parent; }//}}} - //{{{ actionPerformed() + //{{{ actionPerformed() public void actionPerformed(ActionEvent e) { dialog.refreshContents(); - dialog.show(); + dialog.setVisible(true); }//}}} - - /* - public void updateDialog(){ - dialog.refreshContents(); - }*/ } Modified: trunk/jsxe/src/net/sourceforge/jsxe/gui/OptionsDialog.java =================================================================== --- trunk/jsxe/src/net/sourceforge/jsxe/gui/OptionsDialog.java 2006-06-07 06:01:12 UTC (rev 911) +++ trunk/jsxe/src/net/sourceforge/jsxe/gui/OptionsDialog.java 2006-06-07 06:07:44 UTC (rev 912) @@ -317,7 +317,7 @@ // in case saved geometry is too small updateSize(); - show(); + setVisible(true); } //}}} //{{{ selectPane() method Modified: trunk/jsxe/src/net/sourceforge/jsxe/gui/PluginManagerDialog.java =================================================================== --- trunk/jsxe/src/net/sourceforge/jsxe/gui/PluginManagerDialog.java 2006-06-07 06:01:12 UTC (rev 911) +++ trunk/jsxe/src/net/sourceforge/jsxe/gui/PluginManagerDialog.java 2006-06-07 06:07:44 UTC (rev 912) @@ -133,7 +133,8 @@ content.add(buttons, BorderLayout.SOUTH); loadGeometry(this, "pluginmgr"); - show(); + + setVisible(true); }//}}} //{{{ ok() This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
|
From: <ian...@us...> - 2006-06-12 20:22:20
|
Revision: 942 Author: ian_lewis Date: 2006-06-12 13:22:09 -0700 (Mon, 12 Jun 2006) ViewCVS: http://svn.sourceforge.net/jsxe/?rev=942&view=rev Log Message: ----------- moved the global options pane to it's own file Modified Paths: -------------- trunk/jsxe/build.xml trunk/jsxe/messages/messages.en trunk/jsxe/src/net/sourceforge/jsxe/gui/GlobalOptionsDialog.java trunk/jsxe/src/net/sourceforge/jsxe/jsXe.java Added Paths: ----------- trunk/jsxe/src/net/sourceforge/jsxe/options/GeneralOptionPane.java Modified: trunk/jsxe/build.xml =================================================================== --- trunk/jsxe/build.xml 2006-06-12 16:09:07 UTC (rev 941) +++ trunk/jsxe/build.xml 2006-06-12 20:22:09 UTC (rev 942) @@ -70,6 +70,13 @@ </fileset> </path> + <path id="run-classpath"> + <pathelement location="${root.dir}/${app.name}.jar"/> + <fileset dir="${lib.dir}"> + <include name="**/*.jar"/> + </fileset> + </path> + <!-- set whether we have the source for the default views --> <available file="${plugin.dir}/treeview/build.xml" property="treeview.avail"/> <available file="${plugin.dir}/sourceview/build.xml" property="sourceview.avail"/> @@ -193,7 +200,14 @@ <ant inheritAll="false" dir="${plugin.dir}/sourceview/" target="compile"/> </target> <!-- }}} --> - <!-- {{{ ============ Prepares for a build ============================= --> + <!-- {{{ ============ Run the program ================================== --> + <target depends="compile" name="run" description="run jsXe"> + <java fork="true" classname="${main.class}"> + <classpath refid="classpath"/> + </java> + </target> + <!-- }}} --> + <!-- {{{ ============ Prepares for a build ============================= --> <target depends="init" name="prepare-build"> <!-- lib --> <mkdir dir="${build.dir}/lib"/> Modified: trunk/jsxe/messages/messages.en =================================================================== --- trunk/jsxe/messages/messages.en 2006-06-12 16:09:07 UTC (rev 941) +++ trunk/jsxe/messages/messages.en 2006-06-12 20:22:09 UTC (rev 942) @@ -59,7 +59,7 @@ #{{{ Global Options Global.Options.Dialog.Title=Global Options -Global.Options.Title=jsXe Global Options +Global.Options.Title=General Global.Options.Max.Recent.Files=Recent files to remember: Global.Options.Max.Recent.Files.ToolTip=The maximum number of files that jsXe remembers in the recent files menu. Global.Options.network-off=Always cache without asking Modified: trunk/jsxe/src/net/sourceforge/jsxe/gui/GlobalOptionsDialog.java =================================================================== --- trunk/jsxe/src/net/sourceforge/jsxe/gui/GlobalOptionsDialog.java 2006-06-12 16:09:07 UTC (rev 941) +++ trunk/jsxe/src/net/sourceforge/jsxe/gui/GlobalOptionsDialog.java 2006-06-12 20:22:09 UTC (rev 942) @@ -63,7 +63,7 @@ DocumentBuffer buffer = view.getDocumentView().getDocumentBuffer(); - OptionPane pane = jsXe.getOptionPane(); + OptionPane pane = new GeneralOptionPane(); if (pane != null) { addOptionPane(pane); } Modified: trunk/jsxe/src/net/sourceforge/jsxe/jsXe.java =================================================================== --- trunk/jsxe/src/net/sourceforge/jsxe/jsXe.java 2006-06-12 16:09:07 UTC (rev 941) +++ trunk/jsxe/src/net/sourceforge/jsxe/jsXe.java 2006-06-12 20:22:09 UTC (rev 942) @@ -1176,18 +1176,6 @@ return m_actionSets; }//}}} - //{{{ getOptionsPanel() - /** - * Gets the option pane for the jsXe application. - * @return The OptionPane with the options for jsXe. - */ - public static final OptionPane getOptionPane() { - if (jsXeOptions == null) { - jsXeOptions = new jsXeOptionPane(); - } - return jsXeOptions; - }//}}} - //{{{ getPluginLoader() /** * Gets the plugin loader that is used to load @@ -1342,85 +1330,6 @@ }//}}} - //{{{ jsXeOptionPane class - - private static class jsXeOptionPane extends AbstractOptionPane { - - //{{{ jsXeOptionPane constructor - public jsXeOptionPane() { - super("jsxeoptions"); - }//}}} - - //{{{ getTitle() - public String getTitle() { - return Messages.getMessage("Global.Options.Title"); - }//}}} - - //{{{ _init() - protected void _init() { - - //{{{ max recent files - - int maxRecentFiles = jsXe.getIntegerProperty("max.recent.files", 20); - - Vector sizes = new Vector(4); - sizes.add("10"); - sizes.add("20"); - sizes.add("30"); - sizes.add("40"); - maxRecentFilesComboBox = new JComboBox(sizes); - maxRecentFilesComboBox.setEditable(true); - maxRecentFilesComboBox.setSelectedItem(Integer.toString(maxRecentFiles)); - - addComponent(Messages.getMessage("Global.Options.Max.Recent.Files"), - maxRecentFilesComboBox, - Messages.getMessage("Global.Options.Max.Recent.Files.ToolTip")); - - //}}} - - //{{{ network - - String[] networkValues = { - Messages.getMessage("Global.Options.network-always"), - Messages.getMessage("Global.Options.network-cache"), - Messages.getMessage("Global.Options.network-off") - - }; - - network = new JComboBox(networkValues); - network.setSelectedIndex(jsXe.getIntegerProperty("xml.cache", 1)); - - addComponent(Messages.getMessage("Global.Options.network"), - network); - - //}}} - - }//}}} - - //{{{ _save() - protected void _save() { - try { - //don't need to set dirty, no change to text - jsXe.setProperty("max.recent.files", (new Integer(maxRecentFilesComboBox.getSelectedItem().toString())).toString()); - } catch (NumberFormatException nfe) { - //Bad input, don't save. - } - jsXe.setIntegerProperty("xml.cache",network.getSelectedIndex()); - CatalogManager.propertiesChanged(); - }//}}} - - //{{{ toString() - public String toString() { - return getTitle(); - }//}}} - - //{{{ Private Members - private JComboBox maxRecentFilesComboBox; - private JComboBox network; - //}}} - - }//}}} - //{{{ printUsage() private static void printUsage() { Added: trunk/jsxe/src/net/sourceforge/jsxe/options/GeneralOptionPane.java =================================================================== --- trunk/jsxe/src/net/sourceforge/jsxe/options/GeneralOptionPane.java (rev 0) +++ trunk/jsxe/src/net/sourceforge/jsxe/options/GeneralOptionPane.java 2006-06-12 20:22:09 UTC (rev 942) @@ -0,0 +1,118 @@ +/* +GeneralOptionPane.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 net.sourceforge.jsxe.options; + +//{{{ imports +import net.sourceforge.jsxe.jsXe; +import net.sourceforge.jsxe.CatalogManager; +import net.sourceforge.jsxe.gui.Messages; +import javax.swing.JComboBox; +import java.util.Vector; +//}}} + +/** + * The OptionPane containing jsXe's general options in the Global Options + * Dialog. + * + * @author Ian Lewis (<a href="mailto:Ian...@me...">Ian...@me...</a>) + * @version $Id$ + * @see net.sourceforge.jsxe.gui.GlobalOptionsDialog + */ +public class GeneralOptionPane extends AbstractOptionPane { + + //{{{ GeneralOptionPane constructor + public GeneralOptionPane() { + super("jsxeoptions"); + }//}}} + + //{{{ getTitle() + public String getTitle() { + return Messages.getMessage("Global.Options.Title"); + }//}}} + + //{{{ _init() + protected void _init() { + + //{{{ max recent files + + int maxRecentFiles = jsXe.getIntegerProperty("max.recent.files", 20); + + Vector sizes = new Vector(4); + sizes.add("10"); + sizes.add("20"); + sizes.add("30"); + sizes.add("40"); + maxRecentFilesComboBox = new JComboBox(sizes); + maxRecentFilesComboBox.setEditable(true); + maxRecentFilesComboBox.setSelectedItem(Integer.toString(maxRecentFiles)); + + addComponent(Messages.getMessage("Global.Options.Max.Recent.Files"), + maxRecentFilesComboBox, + Messages.getMessage("Global.Options.Max.Recent.Files.ToolTip")); + + //}}} + + //{{{ network + + String[] networkValues = { + Messages.getMessage("Global.Options.network-always"), + Messages.getMessage("Global.Options.network-cache"), + Messages.getMessage("Global.Options.network-off") + + }; + + network = new JComboBox(networkValues); + network.setSelectedIndex(jsXe.getIntegerProperty("xml.cache", 1)); + + addComponent(Messages.getMessage("Global.Options.network"), + network); + + //}}} + + }//}}} + + //{{{ _save() + protected void _save() { + try { + //don't need to set dirty, no change to text + jsXe.setProperty("max.recent.files", (new Integer(maxRecentFilesComboBox.getSelectedItem().toString())).toString()); + } catch (NumberFormatException nfe) { + //Bad input, don't save. + } + jsXe.setIntegerProperty("xml.cache",network.getSelectedIndex()); + CatalogManager.propertiesChanged(); + }//}}} + + //{{{ toString() + public String toString() { + return getTitle(); + }//}}} + + //{{{ Private Members + private JComboBox maxRecentFilesComboBox; + private JComboBox network; + //}}} + +} Property changes on: trunk/jsxe/src/net/sourceforge/jsxe/options/GeneralOptionPane.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-06-13 20:25:43
|
Revision: 951 Author: ian_lewis Date: 2006-06-13 13:25:35 -0700 (Tue, 13 Jun 2006) ViewCVS: http://svn.sourceforge.net/jsxe/?rev=951&view=rev Log Message: ----------- Added an InputManager for maintaining key bindings in jsXe Modified Paths: -------------- trunk/jsxe/Changelog trunk/jsxe/src/net/sourceforge/jsxe/ActionSet.java trunk/jsxe/src/net/sourceforge/jsxe/action/FileCloseAction.java trunk/jsxe/src/net/sourceforge/jsxe/jsXe.java Modified: trunk/jsxe/Changelog =================================================================== --- trunk/jsxe/Changelog 2006-06-13 18:06:18 UTC (rev 950) +++ trunk/jsxe/Changelog 2006-06-13 20:25:35 UTC (rev 951) @@ -1,3 +1,8 @@ +06/13/2006 Ian Lewis <Ian...@me...> + + * Added the InputManager for maintaining the key bindings for actions in + jsXe. + 06/08/2006 Ian Lewis <Ian...@me...> * Added a PropertyChanged event for when one of jsXe's properties changes. Modified: trunk/jsxe/src/net/sourceforge/jsxe/ActionSet.java =================================================================== --- trunk/jsxe/src/net/sourceforge/jsxe/ActionSet.java 2006-06-13 18:06:18 UTC (rev 950) +++ trunk/jsxe/src/net/sourceforge/jsxe/ActionSet.java 2006-06-13 20:25:35 UTC (rev 951) @@ -39,7 +39,6 @@ public class ActionSet { //{{{ ActionSet constructor - /** * Creates a new action set. */ @@ -48,7 +47,6 @@ }//}}} //{{{ ActionSet constructor - /** * Creates a new action set. * @param label The label for the action set @@ -59,7 +57,6 @@ }//}}} //{{{ getLabel() - /** * Return the action source label. */ @@ -68,7 +65,6 @@ }//}}} //{{{ setLabel() - /** * Sets the action source label. * @param label The label @@ -78,7 +74,6 @@ }//}}} //{{{ addAction() - /** * Adds an action to the action set. * @param name the internal name for the action @@ -89,7 +84,6 @@ }//}}} //{{{ removeAction() - /** * Removes an action from the action set. * @param name The internal action name @@ -99,7 +93,6 @@ }//}}} //{{{ removeAllActions() - /** * Removes all actions from the action set. */ @@ -108,7 +101,6 @@ }//}}} //{{{ getAction() - /** * Returns an action with the specified name. * @param name The action name @@ -118,7 +110,6 @@ }//}}} //{{{ getActionCount() - /** * Returns the number of actions in the set. */ @@ -127,7 +118,6 @@ }//}}} //{{{ getActions() - /** * Returns an array of all actions in this action set. */ @@ -142,7 +132,6 @@ }//}}} //{{{ contains() - /** * Returns if this action set contains the specified action. * @param action The action Modified: trunk/jsxe/src/net/sourceforge/jsxe/action/FileCloseAction.java =================================================================== --- trunk/jsxe/src/net/sourceforge/jsxe/action/FileCloseAction.java 2006-06-13 18:06:18 UTC (rev 950) +++ trunk/jsxe/src/net/sourceforge/jsxe/action/FileCloseAction.java 2006-06-13 20:25:35 UTC (rev 951) @@ -57,6 +57,7 @@ /** * The action executed when the user selects 'close' from the file menu. + * * @author Ian Lewis (<a href="mailto:Ian...@me...">Ian...@me...</a>) * @author Trish Hartnett (<a href="mailto:tri...@me...">tri...@me...</a>) * @version $Id$ @@ -64,7 +65,6 @@ public class FileCloseAction extends AbstractAction { //{{{ FileCloseAction constructor - public FileCloseAction(TabbedView parent) { //putValue(Action.NAME, "Close"); putValue(Action.NAME, Messages.getMessage("File.Close")); Modified: trunk/jsxe/src/net/sourceforge/jsxe/jsXe.java =================================================================== --- trunk/jsxe/src/net/sourceforge/jsxe/jsXe.java 2006-06-13 18:06:18 UTC (rev 950) +++ trunk/jsxe/src/net/sourceforge/jsxe/jsXe.java 2006-06-13 20:25:35 UTC (rev 951) @@ -929,6 +929,8 @@ System.exit(errorcode); }//}}} + //{{{ Properties methods + //{{{ setProperty() /** * Sets a global property to jsXe. @@ -1140,6 +1142,10 @@ setIntegerProperty(name + "style",value.getStyle()); } //}}} + //}}} + + //{{{ Action methods + //{{{ addActionSet() /** * Adds a set of actions to the jsXe's pool of action sets. @@ -1176,6 +1182,8 @@ return m_actionSets; }//}}} + //}}} + //{{{ getPluginLoader() /** * Gets the plugin loader that is used to load This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
|
From: <ian...@us...> - 2006-06-14 19:01:58
|
Revision: 954 Author: ian_lewis Date: 2006-06-14 12:01:14 -0700 (Wed, 14 Jun 2006) ViewCVS: http://svn.sourceforge.net/jsxe/?rev=954&view=rev Log Message: ----------- Added the EditAction class for use later with jsXe's actions Modified Paths: -------------- trunk/jsxe/Changelog Added Paths: ----------- trunk/jsxe/src/net/sourceforge/jsxe/EditAction.java Modified: trunk/jsxe/Changelog =================================================================== --- trunk/jsxe/Changelog 2006-06-13 20:53:03 UTC (rev 953) +++ trunk/jsxe/Changelog 2006-06-14 19:01:14 UTC (rev 954) @@ -1,3 +1,10 @@ +06/14/2006 Ian Lewis <Ian...@me...> + + * Added the EditAction class for future actions in jsXe. + The messages, menu mnemonics, and tooltips will be able to be + localized and the shortcuts will be able to be set via the + InputManager. + 06/13/2006 Ian Lewis <Ian...@me...> * Added the InputManager for maintaining the key bindings for actions in Added: trunk/jsxe/src/net/sourceforge/jsxe/EditAction.java =================================================================== --- trunk/jsxe/src/net/sourceforge/jsxe/EditAction.java (rev 0) +++ trunk/jsxe/src/net/sourceforge/jsxe/EditAction.java 2006-06-14 19:01:14 UTC (rev 954) @@ -0,0 +1,69 @@ +/* +EditAction.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 net.sourceforge.jsxe; + +/** + * An action that can be used by jsXe. These actions are registered + * with jsXe through ActionSets. These ActionSets can be registered with + * jsXe by plugins. Once an EditAction is included in an ActionSet and + * registered with jsXe via the <code>addActionSet()</code> method, + * key bindings can be associated to the action via the InputManager. + * + * @author Ian Lewis (<a href="mailto:Ian...@me...">Ian...@me...</a>) + * @version $Id$ + * @see jsXe + * @see ActionSet + * @see InputManager + */ +public abstract class EditAction { + + // {{{ Public static members + /** + * The internal name of the action used for retrieval from + * <code>jsXe.getAction(String)</code> and for storing properties related + * to the action. + */ + public static final String INTERNAL_NAME = "internal-name"; + /** + * The message name of the action used to retrieve the localized + * human readable text for the action. The text is retrieved from + * the net.sourceforge.jsxe.Messages class. + */ + public static final String MESSAGE_NAME = "message-name"; + /** + * The message name for the localized tooltip message that + * is associated with this action. + */ + public static final String TOOLTIP_MESSAGE_NAME = "tooltip-message-name"; + //}}} + + //{{{ invoke() + /** + * The method that is run when the action is invoked. + * @param view the view that invoked the action. + * @param evt the ActionEvent for this event. + */ + public abstract void invoke(TabbedView view, ActionEvent evt);//}}} +} Property changes on: trunk/jsxe/src/net/sourceforge/jsxe/EditAction.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-07-28 20:23:09
|
Revision: 1067 Author: ian_lewis Date: 2006-07-26 09:56:28 -0700 (Wed, 26 Jul 2006) ViewCVS: http://svn.sourceforge.net/jsxe/?rev=1067&view=rev Log Message: ----------- Fixed a bug where the shortcuts for Built-In commands were not being honored. Modified Paths: -------------- trunk/jsxe/Changelog trunk/jsxe/src/net/sourceforge/jsxe/ActionManager.java trunk/jsxe/src/net/sourceforge/jsxe/jsXe.java Modified: trunk/jsxe/Changelog =================================================================== --- trunk/jsxe/Changelog 2006-07-26 15:30:29 UTC (rev 1066) +++ trunk/jsxe/Changelog 2006-07-26 16:56:28 UTC (rev 1067) @@ -2,6 +2,8 @@ * Updated the find and findnext actions to use proper messages labels. + * Fixed a bug where the shortcuts for Built-In commands were not being + honored. 07/24/2006 Ian Lewis <Ian...@me...> Modified: trunk/jsxe/src/net/sourceforge/jsxe/ActionManager.java =================================================================== --- trunk/jsxe/src/net/sourceforge/jsxe/ActionManager.java 2006-07-26 15:30:29 UTC (rev 1066) +++ trunk/jsxe/src/net/sourceforge/jsxe/ActionManager.java 2006-07-26 16:56:28 UTC (rev 1067) @@ -82,6 +82,7 @@ public static final String COPY_SUFFIX = ".copy"; public static final String PASTE_SUFFIX = ".paste"; public static final String FIND_SUFFIX = ".find"; + public static final String FIND_NEXT_SUFFIX = ".findnext"; //}}} @@ -173,27 +174,6 @@ Log.log(Log.NOTICE, ActionManager.class, "Loading key bindings."); if (!initialized) { - //Add EditBus Listener to update key bindings when properties are changed - EditBus.addToBus(new EBListener() { - - //{{{ handleMessage() - public void handleMessage(EBMessage message) { - if (message instanceof PropertyChanged) { - PropertyChanged msg = (PropertyChanged)message; - if (msg.getKey().endsWith(".shortcut")) { - String actionName = msg.getKey().substring(0, msg.getKey().lastIndexOf(".")); - String keyBinding = jsXe.getProperty(msg.getKey()); - if (keyBinding != null) { - addKeyBinding(keyBinding, actionName); - } else { - removeKeyBinding(msg.getOldValue()); - } - } - } - }//}}} - - }); - Iterator itr = m_actionSets.iterator(); while (itr.hasNext()) { ActionSet set = (ActionSet)itr.next(); @@ -233,9 +213,15 @@ if (action != null && keyBinding != null) { Action wrapper = getAction(action.getName()); + + KeyEventTranslator.Key key = KeyEventTranslator.parseKey(keyBinding); m_keyBindingMap.put(key, wrapper); + Log.log(Log.DEBUG, ActionManager.class, "Adding binding: "+key.toString()); + Log.log(Log.DEBUG, ActionManager.class, "key.key: "+key.key); + Log.log(Log.DEBUG, ActionManager.class, "key.input: "+key.input); + //need to do this so that the accelerator key is rendered on menu items wrapper.putValue(Action.ACCELERATOR_KEY, KeyEventTranslator.getKeyStroke(keyBinding)); } @@ -268,6 +254,9 @@ */ public static void handleKey(KeyEvent event) { KeyEventTranslator.Key key = KeyEventTranslator.translateKeyEvent(event); + Log.log(Log.DEBUG, ActionManager.class, "Key: "+key.toString()); + Log.log(Log.DEBUG, ActionManager.class, "key.key: "+key.key); + Log.log(Log.DEBUG, ActionManager.class, "key.input: "+key.input); //Gets the action for the Key. Action action = (Action)m_keyBindingMap.get(key); @@ -286,7 +275,8 @@ return (actionName.endsWith(CUT_SUFFIX) || actionName.endsWith(COPY_SUFFIX) || actionName.endsWith(PASTE_SUFFIX) || - actionName.endsWith(FIND_SUFFIX)); + actionName.endsWith(FIND_SUFFIX) || + actionName.endsWith(FIND_NEXT_SUFFIX)); }//}}} //{{{ Wrapper class Modified: trunk/jsxe/src/net/sourceforge/jsxe/jsXe.java =================================================================== --- trunk/jsxe/src/net/sourceforge/jsxe/jsXe.java 2006-07-26 15:30:29 UTC (rev 1066) +++ trunk/jsxe/src/net/sourceforge/jsxe/jsXe.java 2006-07-26 16:56:28 UTC (rev 1067) @@ -321,15 +321,32 @@ initPLAF(); //}}} - //{{{ init key bindings + //{{{ Add EditBus Listener to update key bindings when properties are changed /* - key bindings are loaded before the TabbedView is created - so that the ActionManagers EBListener is added to the EditBus first - Hopefully this is a temporary problem. + This must be done before creating the TabbedView so that + the ActionManager's listener is notified of changes first. */ - ActionManager.initKeyBindings(); - //}}} + EditBus.addToBus(new EBListener() { + + //{{{ handleMessage() + public void handleMessage(EBMessage message) { + if (message instanceof PropertyChanged) { + PropertyChanged msg = (PropertyChanged)message; + if (msg.getKey().endsWith(".shortcut")) { + String actionName = msg.getKey().substring(0, msg.getKey().lastIndexOf(".")); + String keyBinding = jsXe.getProperty(msg.getKey()); + if (keyBinding != null) { + ActionManager.addKeyBinding(keyBinding, actionName); + } else { + ActionManager.removeKeyBinding(msg.getOldValue()); + } + } + } + }//}}} + + });//}}} + //{{{ create the TabbedView Log.log(Log.NOTICE, jsXe.class, "Starting the main window"); TabbedView tabbedview = null; @@ -366,6 +383,10 @@ progressScreen.updateSplashScreenDialog(85); //}}} + //{{{ init key bindings + ActionManager.initKeyBindings(); + //}}} + //{{{ Parse files to open on the command line Log.log(Log.NOTICE, jsXe.class, "Parsing files to open on command line"); if (files.size() > 0) { 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:41:24
|
Revision: 1214
http://svn.sourceforge.net/jsxe/?rev=1214&view=rev
Author: ian_lewis
Date: 2006-08-31 13:41:10 -0700 (Thu, 31 Aug 2006)
Log Message:
-----------
merge from 05pre3 branch rev. 1213
Modified Paths:
--------------
trunk/jsxe/Changelog
trunk/jsxe/messages/messages.properties
trunk/jsxe/src/net/sourceforge/jsxe/ActionManager.java
trunk/jsxe/src/net/sourceforge/jsxe/LocalizedAction.java
trunk/jsxe/src/net/sourceforge/jsxe/action/CopyAction.java
trunk/jsxe/src/net/sourceforge/jsxe/action/CutAction.java
trunk/jsxe/src/net/sourceforge/jsxe/action/FindAction.java
trunk/jsxe/src/net/sourceforge/jsxe/action/FindNextAction.java
trunk/jsxe/src/net/sourceforge/jsxe/action/PasteAction.java
trunk/jsxe/src/net/sourceforge/jsxe/gui/GUIUtilities.java
trunk/jsxe/src/net/sourceforge/jsxe/gui/TabbedView.java
trunk/jsxe/src/net/sourceforge/jsxe/options/ShortcutsOptionPane.java
Added Paths:
-----------
trunk/jsxe/src/net/sourceforge/jsxe/action/ContextSpecificAction.java
Removed Paths:
-------------
trunk/jsxe/src/net/sourceforge/jsxe/action/ViewSpecificAction.java
Modified: trunk/jsxe/Changelog
===================================================================
--- trunk/jsxe/Changelog 2006-08-31 20:20:36 UTC (rev 1213)
+++ trunk/jsxe/Changelog 2006-08-31 20:41:10 UTC (rev 1214)
@@ -1,3 +1,9 @@
+08/31/2006 Ian Lewis <Ian...@me...>
+
+ * Added new ContextSpecificActions to replace ViewSpecificActions. Now
+ actions such as cut and paste can be registered for specific components
+ not just a specific view.
+
08/29/2006 Ian Lewis <Ian...@me...>
* Fixed a memory leak with JMenuItems. ActionManager kept a cache of
Modified: trunk/jsxe/messages/messages.properties
===================================================================
--- trunk/jsxe/messages/messages.properties 2006-08-31 20:20:36 UTC (rev 1213)
+++ trunk/jsxe/messages/messages.properties 2006-08-31 20:41:10 UTC (rev 1214)
@@ -236,6 +236,10 @@
No.Xerces.Error.title={0} not found.
IO.Error.title=I/O Error
IO.Error.message=An I/O error has occurred
+
+#generic error message
+XML.Error.title=XML Error
+XML.Error.message={0}
#}}}
#}}}
Modified: trunk/jsxe/src/net/sourceforge/jsxe/ActionManager.java
===================================================================
--- trunk/jsxe/src/net/sourceforge/jsxe/ActionManager.java 2006-08-31 20:20:36 UTC (rev 1213)
+++ trunk/jsxe/src/net/sourceforge/jsxe/ActionManager.java 2006-08-31 20:41:10 UTC (rev 1214)
@@ -27,13 +27,13 @@
//{{{ imports
//{{{ jsXe classes
+import net.sourceforge.jsxe.action.ContextSpecificAction;
import net.sourceforge.jsxe.gui.Messages;
import net.sourceforge.jsxe.gui.GUIUtilities;
import net.sourceforge.jsxe.gui.KeyEventTranslator;
import net.sourceforge.jsxe.util.Log;
import net.sourceforge.jsxe.util.MiscUtilities;
import net.sourceforge.jsxe.msg.PropertyChanged;
-import net.sourceforge.jsxe.action.ViewSpecificAction;
//}}}
//{{{ Java classes
@@ -49,6 +49,7 @@
//}}}
//{{{ AWT classes
+import java.awt.Component;
import java.awt.event.ActionEvent;
import java.awt.event.KeyEvent;
//}}}
@@ -73,16 +74,6 @@
*/
public class ActionManager {
- //{{{ Public static identifiers
-
- public static final String CUT_SUFFIX = ".cut";
- public static final String COPY_SUFFIX = ".copy";
- public static final String PASTE_SUFFIX = ".paste";
- public static final String FIND_SUFFIX = ".find";
- public static final String FIND_NEXT_SUFFIX = ".findnext";
-
- //}}}
-
//{{{ addActionSet()
/**
* Adds a set of actions to the jsXe's pool of action sets.
@@ -94,11 +85,51 @@
m_actionSets.add(set);
}//}}}
+ //{{{ addActionImplementation()
+ /**
+ * Register an ActionImplementation with a registered ContextSpecificAction.
+ * If the ContextSpecificAction isn't registered this method does nothing.
+ * @param actionName the name of the ContextSpecificAction
+ * @param comp the component context the recieves the action
+ * @param imp the action implementation
+ */
+ public static void addActionImplementation(String actionName, Component comp, ContextSpecificAction.ActionImplementation imp) {
+ ContextSpecificAction action = getContextSpecificAction(actionName);
+ if (action != null) {
+ action.registerComponent(comp, imp);
+ }
+ }//}}}
+
+ //{{{ removeActionImplementation()
+ /**
+ * Removes the ActionImplementation from the registered
+ * ContextSpecificAction.
+ */
+ public static void removeActionImplementation(String actionName, Component comp) {
+ ContextSpecificAction action = getContextSpecificAction(actionName);
+ if (action != null) {
+ action.removeComponent(comp);
+ }
+ }//}}}
+
+ //{{{ getContextSpecificAction()
+ /**
+ * Gets a context specific action or null if no context specific action
+ * exists with that name.
+ */
+ public static ContextSpecificAction getContextSpecificAction(String name) {
+ LocalizedAction action = getLocalizedAction(name);
+ if (action instanceof ContextSpecificAction) {
+ return (ContextSpecificAction)action;
+ }
+ return null;
+ }//}}}
+
//{{{ getLocalizedAction()
/**
* Gets the LocalizedAction set with the given name
- * @param the name of the action set.
- * @return the action set that matches the name, or null if none match.
+ * @param the name of the action.
+ * @return the action that matches the name, or null if none match.
*/
public static LocalizedAction getLocalizedAction(String name) {
for (int i = 0; i < m_actionSets.size(); i++) {
@@ -113,8 +144,8 @@
//{{{ getAction()
/**
- * Gets a true action for the LocalizedAction with the given name. This can be
- * used in menus and toobars etc.
+ * Creates a true action for the LocalizedAction with the given name. This
+ * can be used in menus and toobars etc.
* @param name the name of the action.
*/
public static Action getAction(String name) {
@@ -267,18 +298,6 @@
}
}//}}}
- //{{{ isDocviewSpecific()
- /**
- * Returns whether the action with the given name is document view specific.
- */
- public static boolean isDocViewSpecific(String actionName) {
- return (actionName.endsWith(CUT_SUFFIX) ||
- actionName.endsWith(COPY_SUFFIX) ||
- actionName.endsWith(PASTE_SUFFIX) ||
- actionName.endsWith(FIND_SUFFIX) ||
- actionName.endsWith(FIND_NEXT_SUFFIX));
- }//}}}
-
//{{{ Wrapper class
/**
* The Wrapper class wraps LocalizedActions so they can be invoked
Modified: trunk/jsxe/src/net/sourceforge/jsxe/LocalizedAction.java
===================================================================
--- trunk/jsxe/src/net/sourceforge/jsxe/LocalizedAction.java 2006-08-31 20:20:36 UTC (rev 1213)
+++ trunk/jsxe/src/net/sourceforge/jsxe/LocalizedAction.java 2006-08-31 20:41:10 UTC (rev 1214)
@@ -45,7 +45,7 @@
* @version $Id$
* @see jsXe
* @see ActionSet
- * @see InputManager
+ * @see ActionManager
* @since jsXe 0.5 pre1
*/
public abstract class LocalizedAction {
Copied: trunk/jsxe/src/net/sourceforge/jsxe/action/ContextSpecificAction.java (from rev 1213, tags/05pre3/jsxe/src/net/sourceforge/jsxe/action/ContextSpecificAction.java)
===================================================================
--- trunk/jsxe/src/net/sourceforge/jsxe/action/ContextSpecificAction.java (rev 0)
+++ trunk/jsxe/src/net/sourceforge/jsxe/action/ContextSpecificAction.java 2006-08-31 20:41:10 UTC (rev 1214)
@@ -0,0 +1,146 @@
+/*
+ContextSpecificAction.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 net.sourceforge.jsxe.action;
+
+//{{{ imports
+
+//{{{ 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.GUIUtilities;
+//}}}
+
+//{{{ Java classes
+import java.io.IOException;
+import java.util.HashMap;
+import java.util.Iterator;
+//}}}
+
+//{{{ AWT components
+import java.awt.event.ActionEvent;
+import java.awt.Component;
+import java.awt.KeyboardFocusManager;
+//}}}
+
+//}}}
+
+/**
+ * The ContextSpecificAction is a class that defines actions that are
+ * context specific. i.e. Actions that are defined by jsXe but whose
+ * implementation is determined by the context or component that
+ * currently has focus.
+ *
+ * The ContextSpecificAction class allows components to be assocatied
+ * with a specific action implementation that is specific to that context
+ * (component). When the ContextSpecificAction is run, the action will
+ * search the registered components. If the component that has focus is owned
+ * by registered component then the action implementation associated with
+ * that component is then invoked.
+ *
+ * The order of the search is not specified and the first match that is found
+ * will be invoked.
+ *
+ * Examples where this class may be useful is cut, copy, paste, insert, or
+ * delete where the implementation may depend on the components implementation.
+ *
+ * @author Ian Lewis (<a href="mailto:Ian...@me...">Ian...@me...</a>)
+ * @version $Id$
+ * @since jsXe 0.5 pre3
+ */
+public abstract class ContextSpecificAction extends LocalizedAction {
+
+ //{{{ ContextSpecificAction constructor
+ public ContextSpecificAction(String name) {
+ super(name);
+ }//}}}
+
+ //{{{ invoke()
+ /**
+ * Invokes the specific ActionImplementation for the component in
+ * the current context. This method should generally not be overridden by
+ * subclasses.
+ */
+ public void invoke(TabbedView view, ActionEvent evt) {
+ /*
+ Invoke the action registered for the current component named
+ */
+ Component comp = KeyboardFocusManager.getCurrentKeyboardFocusManager().getPermanentFocusOwner();
+ Iterator itr = m_actionMap.keySet().iterator();
+ while (itr.hasNext()) {
+ Component key = (Component)itr.next();
+ if (GUIUtilities.isComponentParentOf(key, comp)) {
+ ActionImplementation imp = (ActionImplementation)m_actionMap.get(key);
+ imp.invoke(view, key, evt);
+ return;
+ }
+ }
+ }//}}}
+
+ //{{{ registerComponent()
+ /**
+ * Adds a component and implementation to the action map for this
+ * action.
+ * @param comp The component that will recieve the action
+ * @param imp the action implementation that implements the action for the
+ * given component.
+ */
+ public void registerComponent(Component comp, ActionImplementation imp) {
+ m_actionMap.put(comp, imp);
+ }//}}}
+
+ //{{{ removeComponent()
+ /**
+ * Removes the component from the action map for this action
+ */
+ public void removeComponent(Component comp) {
+ m_actionMap.remove(comp);
+ }//}}}
+
+ //{{{ interface ActionImplementation
+ /**
+ * An ActionImplementation is an implementation of an action that can be
+ * registered with a ContextSpecificAction and run in a context.
+ */
+ public static interface ActionImplementation {
+
+ /**
+ * This method is run when the ContextSpecificAction is run and
+ * the registered component has focus.
+ * @param view the view that invoked the action
+ * @param comp the registered component
+ * @param evt the event that triggered the action
+ */
+ public void invoke(TabbedView view, Component comp, ActionEvent evt);
+
+ }//}}}
+
+ //{{{ Private Members
+
+ private HashMap m_actionMap = new HashMap();
+
+ //}}}
+}
Modified: trunk/jsxe/src/net/sourceforge/jsxe/action/CopyAction.java
===================================================================
--- trunk/jsxe/src/net/sourceforge/jsxe/action/CopyAction.java 2006-08-31 20:20:36 UTC (rev 1213)
+++ trunk/jsxe/src/net/sourceforge/jsxe/action/CopyAction.java 2006-08-31 20:41:10 UTC (rev 1214)
@@ -40,9 +40,13 @@
//}}}
//{{{ AWT components
+import java.awt.Component;
+import java.awt.KeyboardFocusManager;
import java.awt.event.ActionEvent;
//}}}
+import javax.swing.text.JTextComponent;
+
//}}}
/**
@@ -53,11 +57,23 @@
* @version $Id$
* @since jsXe 0.5 pre1
*/
-public class CopyAction extends ViewSpecificAction {
+public class CopyAction extends ContextSpecificAction {
//{{{ CopyAction constructor
public CopyAction() {
super("copy");
}//}}}
+ //{{{ invoke()
+ public void invoke(TabbedView view, ActionEvent evt) {
+ /*
+ Invoke the action registered for the current component named
+ */
+ Component comp = KeyboardFocusManager.getCurrentKeyboardFocusManager().getPermanentFocusOwner();
+ if (comp instanceof JTextComponent) {
+ ((JTextComponent)comp).copy();
+ } else {
+ super.invoke(view, evt);
+ }
+ }//}}}
}
Modified: trunk/jsxe/src/net/sourceforge/jsxe/action/CutAction.java
===================================================================
--- trunk/jsxe/src/net/sourceforge/jsxe/action/CutAction.java 2006-08-31 20:20:36 UTC (rev 1213)
+++ trunk/jsxe/src/net/sourceforge/jsxe/action/CutAction.java 2006-08-31 20:41:10 UTC (rev 1214)
@@ -40,9 +40,13 @@
//}}}
//{{{ AWT components
+import java.awt.Component;
+import java.awt.KeyboardFocusManager;
import java.awt.event.ActionEvent;
//}}}
+import javax.swing.text.JTextComponent;
+
//}}}
/**
@@ -52,11 +56,24 @@
* @version $Id$
* @since jsXe 0.5 pre1
*/
-public class CutAction extends ViewSpecificAction {
+public class CutAction extends ContextSpecificAction {
//{{{ CutAction constructor
public CutAction() {
super("cut");
}//}}}
+ //{{{ invoke()
+ public void invoke(TabbedView view, ActionEvent evt) {
+ /*
+ Invoke the action registered for the current component named
+ */
+ Component comp = KeyboardFocusManager.getCurrentKeyboardFocusManager().getPermanentFocusOwner();
+ if (comp instanceof JTextComponent) {
+ ((JTextComponent)comp).cut();
+ } else {
+ super.invoke(view, evt);
+ }
+ }//}}}
+
}
Modified: trunk/jsxe/src/net/sourceforge/jsxe/action/FindAction.java
===================================================================
--- trunk/jsxe/src/net/sourceforge/jsxe/action/FindAction.java 2006-08-31 20:20:36 UTC (rev 1213)
+++ trunk/jsxe/src/net/sourceforge/jsxe/action/FindAction.java 2006-08-31 20:41:10 UTC (rev 1214)
@@ -53,7 +53,7 @@
* @version $Id$
* @since jsXe 0.5 pre1
*/
-public class FindAction extends ViewSpecificAction {
+public class FindAction extends ContextSpecificAction {
//{{{ FindAction constructor
public FindAction() {
Modified: trunk/jsxe/src/net/sourceforge/jsxe/action/FindNextAction.java
===================================================================
--- trunk/jsxe/src/net/sourceforge/jsxe/action/FindNextAction.java 2006-08-31 20:20:36 UTC (rev 1213)
+++ trunk/jsxe/src/net/sourceforge/jsxe/action/FindNextAction.java 2006-08-31 20:41:10 UTC (rev 1214)
@@ -53,7 +53,7 @@
* @version $Id$
* @since jsXe 0.5 pre1
*/
-public class FindNextAction extends ViewSpecificAction {
+public class FindNextAction extends ContextSpecificAction {
//{{{ FindNextAction constructor
public FindNextAction() {
Modified: trunk/jsxe/src/net/sourceforge/jsxe/action/PasteAction.java
===================================================================
--- trunk/jsxe/src/net/sourceforge/jsxe/action/PasteAction.java 2006-08-31 20:20:36 UTC (rev 1213)
+++ trunk/jsxe/src/net/sourceforge/jsxe/action/PasteAction.java 2006-08-31 20:41:10 UTC (rev 1214)
@@ -40,9 +40,13 @@
//}}}
//{{{ AWT components
+import java.awt.Component;
+import java.awt.KeyboardFocusManager;
import java.awt.event.ActionEvent;
//}}}
+import javax.swing.text.JTextComponent;
+
//}}}
/**
@@ -53,11 +57,24 @@
* @version $Id$
* @since jsXe 0.5 pre1
*/
-public class PasteAction extends ViewSpecificAction {
+public class PasteAction extends ContextSpecificAction {
//{{{ PasteAction constructor
public PasteAction() {
super("paste");
}//}}}
-}
+ //{{{ invoke()
+ public void invoke(TabbedView view, ActionEvent evt) {
+ /*
+ Invoke the action registered for the current component named
+ */
+ Component comp = KeyboardFocusManager.getCurrentKeyboardFocusManager().getPermanentFocusOwner();
+ if (comp instanceof JTextComponent) {
+ ((JTextComponent)comp).paste();
+ } else {
+ super.invoke(view, evt);
+ }
+ }//}}}
+
+}
\ No newline at end of file
Deleted: trunk/jsxe/src/net/sourceforge/jsxe/action/ViewSpecificAction.java
===================================================================
--- trunk/jsxe/src/net/sourceforge/jsxe/action/ViewSpecificAction.java 2006-08-31 20:20:36 UTC (rev 1213)
+++ trunk/jsxe/src/net/sourceforge/jsxe/action/ViewSpecificAction.java 2006-08-31 20:41:10 UTC (rev 1214)
@@ -1,81 +0,0 @@
-/*
-ViewSpecificAction.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 net.sourceforge.jsxe.action;
-
-//{{{ imports
-
-//{{{ jsXe classes
-import net.sourceforge.jsxe.jsXe;
-import net.sourceforge.jsxe.JARClassLoader;
-import net.sourceforge.jsxe.ActionManager;
-import net.sourceforge.jsxe.LocalizedAction;
-import net.sourceforge.jsxe.gui.TabbedView;
-import net.sourceforge.jsxe.gui.Messages;
-//}}}
-
-//{{{ Java classes
-import java.io.IOException;
-//}}}
-
-//{{{ AWT components
-import java.awt.event.ActionEvent;
-//}}}
-
-//}}}
-
-/**
- * The ViewSpecificAction is a class that defines actions that are
- * view specific. i.e. Actions that are defined by jsXe but whose
- * implementation is determined by the currently active view.
- *
- * @author Ian Lewis (<a href="mailto:Ian...@me...">Ian...@me...</a>)
- * @version $Id$
- * @since jsXe 0.5 pre3
- */
-public abstract class ViewSpecificAction extends LocalizedAction {
-
- //{{{ ViewSpecificAction constructor
- public ViewSpecificAction(String name) {
- super(name);
- }//}}}
-
- //{{{ invoke()
- public void invoke(TabbedView view, ActionEvent evt) {
- /*
- invoke the action registered for the current DocumentView named
- viewname.actionname if there is one.
- */
- ActionManager.invokeAction(getViewActionName(view), evt);
- }//}}}
-
- //{{{ getViewActionName()
- /**
- * Gets the view specific action name for the current DocumentView in the
- * given TabbedView.
- */
- private String getViewActionName(TabbedView view) {
- return jsXe.getPluginLoader().getPluginProperty(view.getDocumentView().getViewPlugin(), JARClassLoader.PLUGIN_NAME)+"."+getName();
- }//}}}
-}
Modified: trunk/jsxe/src/net/sourceforge/jsxe/gui/GUIUtilities.java
===================================================================
--- trunk/jsxe/src/net/sourceforge/jsxe/gui/GUIUtilities.java 2006-08-31 20:20:36 UTC (rev 1213)
+++ trunk/jsxe/src/net/sourceforge/jsxe/gui/GUIUtilities.java 2006-08-31 20:41:10 UTC (rev 1214)
@@ -1271,6 +1271,40 @@
return (p instanceof JDialog) ? (JDialog) p : null;
} //}}}
+ //{{{ isComponentParentOf() method
+ /**
+ * Returns true if the parent is a parent component of child.
+ * @param parent the parent component
+ * @param child the child component
+ * @since jsXe 0.5 pre3
+ */
+ public static boolean isComponentParentOf(Component parent, Component child) {
+ Component comp = child;
+ for(;;) {
+ if (comp == null) {
+ break;
+ }
+
+ if (comp instanceof JComponent) {
+ Component real = (Component)((JComponent)comp).getClientProperty("KORTE_REAL_FRAME");
+ if (real != null) {
+ comp = real;
+ }
+ }
+
+ if (comp.equals(parent)) {
+ return true;
+ } else {
+ if (comp instanceof JPopupMenu) {
+ comp = ((JPopupMenu)comp).getInvoker();
+ } else {
+ comp = comp.getParent();
+ }
+ }
+ }
+ return false;
+ }//}}}
+
//{{{ getComponentParent() method
/**
* Finds a parent of the specified component.
Modified: trunk/jsxe/src/net/sourceforge/jsxe/gui/TabbedView.java
===================================================================
--- trunk/jsxe/src/net/sourceforge/jsxe/gui/TabbedView.java 2006-08-31 20:20:36 UTC (rev 1213)
+++ trunk/jsxe/src/net/sourceforge/jsxe/gui/TabbedView.java 2006-08-31 20:41:10 UTC (rev 1214)
@@ -589,69 +589,68 @@
m_editMenu.add(menuItem);
m_editMenu.addSeparator();
Action action = ActionManager.getAction("cut");
- if (view != null) {
- String name = jsXe.getPluginLoader().getPluginProperty(view.getViewPlugin(), JARClassLoader.PLUGIN_NAME)+".cut";
- if (ActionManager.getLocalizedAction(name) == null) {
- action.setEnabled(false);
- } else {
- action.setEnabled(true);
- }
- } else {
- action.setEnabled(false);
- }
+ // if (view != null) {
+ // if (ActionManager.getLocalizedAction(name) == null) {
+ // action.setEnabled(false);
+ // } else {
+ // action.setEnabled(true);
+ // }
+ // } else {
+ // action.setEnabled(false);
+ // }
menuItem = new JMenuItem(action);
m_editMenu.add(menuItem);
action = ActionManager.getAction("copy");
- if (view != null) {
- String name = jsXe.getPluginLoader().getPluginProperty(view.getViewPlugin(), JARClassLoader.PLUGIN_NAME)+".copy";
- if (ActionManager.getLocalizedAction(name) == null) {
- action.setEnabled(false);
- } else {
- action.setEnabled(true);
- }
- } else {
- action.setEnabled(false);
- }
+ // if (view != null) {
+ // String name = jsXe.getPluginLoader().getPluginProperty(view.getViewPlugin(), JARClassLoader.PLUGIN_NAME)+".copy";
+ // if (ActionManager.getLocalizedAction(name) == null) {
+ // action.setEnabled(false);
+ // } else {
+ // action.setEnabled(true);
+ // }
+ // } else {
+ // action.setEnabled(false);
+ // }
menuItem = new JMenuItem(action);
m_editMenu.add(menuItem);
action = ActionManager.getAction("paste");
- if (view != null) {
- String name = jsXe.getPluginLoader().getPluginProperty(view.getViewPlugin(), JARClassLoader.PLUGIN_NAME)+".paste";
- if (ActionManager.getLocalizedAction(name) == null) {
- action.setEnabled(false);
- } else {
- action.setEnabled(true);
- }
- } else {
- action.setEnabled(false);
- }
+ // if (view != null) {
+ // String name = jsXe.getPluginLoader().getPluginProperty(view.getViewPlugin(), JARClassLoader.PLUGIN_NAME)+".paste";
+ // if (ActionManager.getLocalizedAction(name) == null) {
+ // action.setEnabled(false);
+ // } else {
+ // action.setEnabled(true);
+ // }
+ // } else {
+ // action.setEnabled(false);
+ // }
menuItem = new JMenuItem(action);
m_editMenu.add(menuItem);
m_editMenu.addSeparator();
action = ActionManager.getAction("find");
- if (view != null) {
- String name = jsXe.getPluginLoader().getPluginProperty(view.getViewPlugin(), JARClassLoader.PLUGIN_NAME)+".find";
- if (ActionManager.getLocalizedAction(name) == null) {
- action.setEnabled(false);
- } else {
- action.setEnabled(true);
- }
- } else {
- action.setEnabled(false);
- }
+ // if (view != null) {
+ // String name = jsXe.getPluginLoader().getPluginProperty(view.getViewPlugin(), JARClassLoader.PLUGIN_NAME)+".find";
+ // if (ActionManager.getLocalizedAction(name) == null) {
+ // action.setEnabled(false);
+ // } else {
+ // action.setEnabled(true);
+ // }
+ // } else {
+ // action.setEnabled(false);
+ // }
menuItem = new JMenuItem(action);
m_editMenu.add(menuItem);
action = ActionManager.getAction("findnext");
- if (view != null) {
- String name = jsXe.getPluginLoader().getPluginProperty(view.getViewPlugin(), JARClassLoader.PLUGIN_NAME)+".findnext";
- if (ActionManager.getLocalizedAction(name) == null) {
- action.setEnabled(false);
- } else {
- action.setEnabled(true);
- }
- } else {
- action.setEnabled(false);
- }
+ // if (view != null) {
+ // String name = jsXe.getPluginLoader().getPluginProperty(view.getViewPlugin(), JARClassLoader.PLUGIN_NAME)+".findnext";
+ // if (ActionManager.getLocalizedAction(name) == null) {
+ // action.setEnabled(false);
+ // } else {
+ // action.setEnabled(true);
+ // }
+ // } else {
+ // action.setEnabled(false);
+ // }
menuItem = new JMenuItem(action);
m_editMenu.add(menuItem);
}//}}}
Modified: trunk/jsxe/src/net/sourceforge/jsxe/options/ShortcutsOptionPane.java
===================================================================
--- trunk/jsxe/src/net/sourceforge/jsxe/options/ShortcutsOptionPane.java 2006-08-31 20:20:36 UTC (rev 1213)
+++ trunk/jsxe/src/net/sourceforge/jsxe/options/ShortcutsOptionPane.java 2006-08-31 20:41:10 UTC (rev 1214)
@@ -146,10 +146,8 @@
if (label == null) {
Log.log(Log.WARNING, this, names[i]+" has a null label");
} else {
- if (!ActionManager.isDocViewSpecific(names[i])) {
- String binding = jsXe.getProperty(names[i]+".shortcut");
- m_set.add(new GrabKeyDialog.KeyBinding(names[i], label, binding));
- }
+ String binding = jsXe.getProperty(names[i]+".shortcut");
+ m_set.add(new GrabKeyDialog.KeyBinding(names[i], label, binding));
}
}
MiscUtilities.quicksort(m_set, new KeyCompare());
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ian...@us...> - 2006-06-15 17:30:34
|
Revision: 960 Author: ian_lewis Date: 2006-06-15 10:30:21 -0700 (Thu, 15 Jun 2006) ViewCVS: http://svn.sourceforge.net/jsxe/?rev=960&view=rev Log Message: ----------- Added a new status column to the plugin manager dialog Added new plugin properties for the plugin author and release date Modified Paths: -------------- trunk/jsxe/Changelog trunk/jsxe/messages/messages.en trunk/jsxe/src/net/sourceforge/jsxe/JARClassLoader.java trunk/jsxe/src/net/sourceforge/jsxe/PluginDependencyException.java trunk/jsxe/src/net/sourceforge/jsxe/gui/PluginManagerDialog.java Modified: trunk/jsxe/Changelog =================================================================== --- trunk/jsxe/Changelog 2006-06-15 13:11:53 UTC (rev 959) +++ trunk/jsxe/Changelog 2006-06-15 17:30:21 UTC (rev 960) @@ -1,3 +1,8 @@ +06/15/2006 Ian Lewis <Ian...@me...> + + * Added a new Status column to the Plugin Manager dialog + * Added new plugin properties for the plugin author and release date + 06/14/2006 Ian Lewis <Ian...@me...> * Added the EditAction class for future actions in jsXe. Modified: trunk/jsxe/messages/messages.en =================================================================== --- trunk/jsxe/messages/messages.en 2006-06-15 13:11:53 UTC (rev 959) +++ trunk/jsxe/messages/messages.en 2006-06-15 17:30:21 UTC (rev 960) @@ -87,6 +87,16 @@ Document.Options.Soft.Tabs.ToolTip=If this box is checked then tab characters are replaced by spaces. #}}} +#{{{ Plugin Manager +Plugin.Manager.Title=Plugin Manager +Plugin.Manager.Name.Column.Header=Name +Plugin.Manager.Version.Column.Header=Version +Plugin.Manager.Status.Column.Header=Status +Plugin.Manager.Loaded.Status=Loaded +Plugin.Manager.Not.Loaded.Status=Not Loaded +Plugin.Manager.Broken.Status=Error +#}}} + #{{{ Menu Items File.Menu=File @@ -113,7 +123,6 @@ Tools.Document.Options=Document Options... Tools.Plugin=Plugin Manager... Tools.ValidationErrors=Validation Errors... -Plugin.Manager.Title=Plugin Manager Help.About=About jsXe... #}}} @@ -142,6 +151,9 @@ Plugin.Load.Already.Loaded=Plugin {0} already loaded. Plugin.Load.Wrong.Main.Class=Main class is not a plugin class. Plugin.Load.No.Plugin.Class=No plugin class defined. +Plugin.Load.No.Plugin.Name=No plugin name defined. +Plugin.Load.No.Plugin.HR.Name=No plugin human-readable name defined. +Plugin.Load.No.Plugin.Version=No plugin version defined. # {0} plugin name # {1} requirement name Modified: trunk/jsxe/src/net/sourceforge/jsxe/JARClassLoader.java =================================================================== --- trunk/jsxe/src/net/sourceforge/jsxe/JARClassLoader.java 2006-06-15 13:11:53 UTC (rev 959) +++ trunk/jsxe/src/net/sourceforge/jsxe/JARClassLoader.java 2006-06-15 17:30:21 UTC (rev 960) @@ -52,24 +52,36 @@ //{{{ Public static members /** * The manifest property that specifies the plugin name. + * Note: This property is required */ public static final String PLUGIN_NAME = "jsxe-plugin-name"; /** * The manifest property that specifies the plugin class + * Note: This property is required */ public static final String PLUGIN_CLASS = "jsxe-plugin-class"; /** * The manifest property that specifies the plugin version + * Note: This property is required */ public static final String PLUGIN_VERSION = "jsxe-plugin-version"; /** + * The manifest property that specifies a human readable name for the plugin + * Note: This property is required + */ + public static final String PLUGIN_HUMAN_READABLE_NAME = "jsxe-plugin-human-readable-name"; + /** + * The manifest property that specifies the plugin Author + */ + public static final String PLUGIN_AUTHOR = "jsxe-plugin-author"; + /** * The manifest property that specifies the plugin URL */ - public static final String PLUGIN_URL = "jsxe-plugin-url"; + public static final String PLUGIN_RELEASE_DATE = "jsxe-plugin-release-date"; /** - * The manifest property that specifies a human readable name for the plugin + * The manifest property that specifies the plugin URL */ - public static final String PLUGIN_HUMAN_READABLE_NAME = "jsxe-plugin-human-readable-name"; + public static final String PLUGIN_URL = "jsxe-plugin-url"; /** * The manifest property that specifies the plugin description */ @@ -605,6 +617,8 @@ String url = getManifestAttribute(jarFile, PLUGIN_URL); String humanReadableName = getManifestAttribute(jarFile, PLUGIN_HUMAN_READABLE_NAME); String description = getManifestAttribute(jarFile, PLUGIN_DESCRIPTION); + String author = getManifestAttribute(jarFile, PLUGIN_AUTHOR); + String releaseDate = getManifestAttribute(jarFile, PLUGIN_RELEASE_DATE); //prefix with both the plugin name and class m_pluginProperties.setProperty(propPrefix1+PLUGIN_NAME, pluginName); @@ -621,6 +635,14 @@ m_pluginProperties.setProperty(propPrefix1+PLUGIN_URL, url); m_pluginProperties.setProperty(propPrefix2+PLUGIN_URL, url); } + if (author != null) { + m_pluginProperties.setProperty(propPrefix1+PLUGIN_AUTHOR, author); + m_pluginProperties.setProperty(propPrefix2+PLUGIN_AUTHOR, author); + } + if (releaseDate != null) { + m_pluginProperties.setProperty(propPrefix1+PLUGIN_RELEASE_DATE, releaseDate); + m_pluginProperties.setProperty(propPrefix2+PLUGIN_RELEASE_DATE, releaseDate); + } if (humanReadableName != null) { m_pluginProperties.setProperty(propPrefix1+PLUGIN_HUMAN_READABLE_NAME, humanReadableName); m_pluginProperties.setProperty(propPrefix2+PLUGIN_HUMAN_READABLE_NAME, humanReadableName); @@ -656,78 +678,87 @@ String mainPluginClass = getManifestAttribute(jarfile, PLUGIN_CLASS); String pluginName = getManifestAttribute(jarfile, PLUGIN_NAME); + String humanReadableName = getManifestAttribute(jarfile, PLUGIN_HUMAN_READABLE_NAME); + String version = getManifestAttribute(jarfile, PLUGIN_VERSION); if (getPlugin(pluginName) != null) { throw new PluginLoadException(jarfile, Messages.getMessage("Plugin.Load.Already.Loaded", new Object[] { pluginName })); } - if (mainPluginClass != null && pluginName != null) { + if (mainPluginClass == null) { + throw new PluginLoadException(jarfile, Messages.getMessage("Plugin.Load.No.Plugin.Class")); + } + if (pluginName == null) { + throw new PluginLoadException(jarfile, Messages.getMessage("Plugin.Load.No.Plugin.Name")); + } + if (humanReadableName == null) { + throw new PluginLoadException(jarfile, Messages.getMessage("Plugin.Load.No.Plugin.HR.Name")); + } + if (version == null) { + throw new PluginLoadException(jarfile, Messages.getMessage("Plugin.Load.No.Plugin.Version")); + } + try { + + checkDependencies(jarfile); + + //load the plugin's localized messages + Log.log(Log.NOTICE, this, "Loading localized messages for plugin: "+pluginName); + Properties pluginMessages = new Properties(); try { + InputStream stream = jarfile.getInputStream(jarfile.getEntry("messages/messages.en")); + pluginMessages.load(stream); + Messages.loadPluginMessages(pluginMessages); + } catch (IOException e) { + Log.log(Log.WARNING, this, "Plugin "+pluginName+" does not have default messages.en"); + } + try { + InputStream stream = jarfile.getInputStream(jarfile.getEntry("messages/messages."+Messages.getLanguage())); + pluginMessages.load(stream); + Messages.loadPluginMessages(pluginMessages); + } catch (IOException e) { + Log.log(Log.WARNING, this, "Plugin "+pluginName+" does not have localized messages."+Messages.getLanguage()); + } + + Class pluginClass = loadClass(mainPluginClass); + + int modifiers = pluginClass.getModifiers(); + if (!Modifier.isInterface(modifiers) + && !Modifier.isAbstract(modifiers) + && ActionPlugin.class.isAssignableFrom(pluginClass)) { - checkDependencies(jarfile); + Object plugin = pluginClass.newInstance(); - //load the plugin's localized messages - Log.log(Log.NOTICE, this, "Loading localized messages for plugin: "+pluginName); - Properties pluginMessages = new Properties(); - try { - InputStream stream = jarfile.getInputStream(jarfile.getEntry("messages/messages.en")); - pluginMessages.load(stream); - Messages.loadPluginMessages(pluginMessages); - } catch (IOException e) { - Log.log(Log.WARNING, this, "Plugin "+pluginName+" does not have default messages.en"); - } - try { - InputStream stream = jarfile.getInputStream(jarfile.getEntry("messages/messages."+Messages.getLanguage())); - pluginMessages.load(stream); - Messages.loadPluginMessages(pluginMessages); - } catch (IOException e) { - Log.log(Log.WARNING, this, "Plugin "+pluginName+" does not have localized messages."+Messages.getLanguage()); - } - - Class pluginClass = loadClass(mainPluginClass); - - int modifiers = pluginClass.getModifiers(); - if (!Modifier.isInterface(modifiers) - && !Modifier.isAbstract(modifiers) - && ActionPlugin.class.isAssignableFrom(pluginClass)) { - - Object plugin = pluginClass.newInstance(); - - if (ViewPlugin.class.isAssignableFrom(pluginClass)) { - //It's a view plugin - Log.log(Log.NOTICE, this, "Started View Plugin: "+pluginName); - ViewPlugin viewPlugin = (ViewPlugin)plugin; - m_viewPlugins.put(pluginName, viewPlugin); - } else { - //It's an Action plugin - Log.log(Log.NOTICE, this, "Started Action Plugin: "+pluginName); - ActionPlugin actionPlugin = (ActionPlugin)plugin; - m_actionPlugins.put(pluginName, actionPlugin); - } + if (ViewPlugin.class.isAssignableFrom(pluginClass)) { + //It's a view plugin + Log.log(Log.NOTICE, this, "Started View Plugin: "+pluginName); + ViewPlugin viewPlugin = (ViewPlugin)plugin; + m_viewPlugins.put(pluginName, viewPlugin); } else { - /* - It's not a plugin. No biggie. We needed it to be loaded - anyway. - */ - throw new PluginLoadException(jarfile, Messages.getMessage("Plugin.Load.Wrong.Main.Class")); + //It's an Action plugin + Log.log(Log.NOTICE, this, "Started Action Plugin: "+pluginName); + ActionPlugin actionPlugin = (ActionPlugin)plugin; + m_actionPlugins.put(pluginName, actionPlugin); } - } catch (ClassNotFoundException e) { - throw new IOException(e.getMessage()); - } catch (InstantiationException e) { - throw new IOException(e.getMessage()); - } catch (IllegalAccessException e) { - throw new IOException(e.getMessage()); - } catch (PluginDependencyException e) { - m_actionPlugins.put(pluginName, new ActionPlugin.Broken()); - throw e; - } catch (IOException e) { - m_actionPlugins.put(pluginName, new ActionPlugin.Broken()); - throw e; + } else { + /* + It's not a plugin. No biggie. We needed it to be loaded + anyway. + */ + throw new PluginLoadException(jarfile, Messages.getMessage("Plugin.Load.Wrong.Main.Class")); } - - } else { - throw new PluginLoadException(jarfile, Messages.getMessage("Plugin.Load.No.Plugin.Class")); + } catch (ClassNotFoundException e) { + throw new IOException(e.getMessage()); + } catch (InstantiationException e) { + throw new IOException(e.getMessage()); + } catch (IllegalAccessException e) { + throw new IOException(e.getMessage()); + } catch (PluginDependencyException e) { + m_actionPlugins.put(pluginName, new ActionPlugin.Broken()); + throw e; + } catch (IOException e) { + m_actionPlugins.put(pluginName, new ActionPlugin.Broken()); + throw e; } }//}}} Modified: trunk/jsxe/src/net/sourceforge/jsxe/PluginDependencyException.java =================================================================== --- trunk/jsxe/src/net/sourceforge/jsxe/PluginDependencyException.java 2006-06-15 13:11:53 UTC (rev 959) +++ trunk/jsxe/src/net/sourceforge/jsxe/PluginDependencyException.java 2006-06-15 17:30:21 UTC (rev 960) @@ -45,7 +45,7 @@ * @param versionFound the version that was found. */ public PluginDependencyException(String pluginName, String requiredName, String versionRequired, String versionFound) { - super(Messages.getMessage("Plugin.Dependency.Message", new Object[] { pluginName, requiredName, versionRequired, versionFound })); + super(pluginName+": "+Messages.getMessage("Plugin.Dependency.Message", new Object[] { pluginName, requiredName, versionRequired, versionFound })); m_pluginName = pluginName; m_requiredName = requiredName; m_versionRequired = versionRequired; @@ -62,9 +62,9 @@ * @param versionRequired the required version of the required component or plugin */ public PluginDependencyException(String pluginName, String requiredName, String versionRequired) { - super((versionRequired != null) ? + super(pluginName+": "+((versionRequired != null) ? Messages.getMessage("Plugin.Dependency.Not.Found", new Object[] { pluginName, requiredName, versionRequired }) : - Messages.getMessage("Plugin.Dependency.Not.Found2", new Object[] { pluginName, requiredName })); + Messages.getMessage("Plugin.Dependency.Not.Found2", new Object[] { pluginName, requiredName }))); m_pluginName = pluginName; m_requiredName = requiredName; m_versionRequired = versionRequired; @@ -78,7 +78,7 @@ * @param message the message */ public PluginDependencyException(String pluginName, String message) { - super(message); + super(pluginName+": "+message); m_pluginName = pluginName; m_requiredName = null; m_versionRequired = null; Modified: trunk/jsxe/src/net/sourceforge/jsxe/gui/PluginManagerDialog.java =================================================================== --- trunk/jsxe/src/net/sourceforge/jsxe/gui/PluginManagerDialog.java 2006-06-15 13:11:53 UTC (rev 959) +++ trunk/jsxe/src/net/sourceforge/jsxe/gui/PluginManagerDialog.java 2006-06-15 17:30:21 UTC (rev 960) @@ -103,7 +103,33 @@ DefaultListSelectionModel model = (DefaultListSelectionModel)e.getSource(); for (int i=0;i<m_pluginNames.size();i++) { if (model.isSelectedIndex(i)) { - descArea.setText(jsXe.getPluginLoader().getPluginProperty(m_pluginNames.get(i).toString(), JARClassLoader.PLUGIN_DESCRIPTION)); + JARClassLoader loader = jsXe.getPluginLoader(); + String releaseDate = loader.getPluginProperty(m_pluginNames.get(i).toString(), JARClassLoader.PLUGIN_RELEASE_DATE); + String author = loader.getPluginProperty(m_pluginNames.get(i).toString(), JARClassLoader.PLUGIN_AUTHOR); + String url = loader.getPluginProperty(m_pluginNames.get(i).toString(), JARClassLoader.PLUGIN_URL); + String desc = loader.getPluginProperty(m_pluginNames.get(i).toString(), JARClassLoader.PLUGIN_DESCRIPTION); + + StringBuffer text = new StringBuffer(); + if (author != null && !author.equals("")) { + text.append("Author: "); + text.append(author); + text.append("\n"); + } + if (releaseDate != null && !releaseDate.equals("")) { + text.append("Release Date: "); + text.append(releaseDate); + text.append("\n"); + } + if (url != null && !url.equals("")) { + text.append("URL: "); + text.append(url); + text.append("\n"); + } + if (desc != null) { + text.append(desc); + } + + descArea.setText(text.toString()); } } } @@ -163,62 +189,65 @@ } //}}} //{{{ PluginManagerTableModel class - private class PluginManagerTableModel implements TableModel { //{{{ addTableModelListener() - public void addTableModelListener(TableModelListener l) { //nothing }//}}} //{{{ getColumnClass() - public Class getColumnClass(int columnIndex) { return "".getClass(); }//}}} //{{{ getColumnCount() - public int getColumnCount() { - return 2; + return 3; }//}}} //{{{ getColumnName() - public String getColumnName(int columnIndex) { String name = null; - if (columnIndex == 0) { - name = "Name"; + switch (columnIndex) { + case 0: + return Messages.getMessage("Plugin.Manager.Name.Column.Header"); + case 1: + return Messages.getMessage("Plugin.Manager.Version.Column.Header"); + case 2: + return Messages.getMessage("Plugin.Manager.Status.Column.Header"); + default: + throw new Error("Column out of range"); } - if (columnIndex == 1) { - name = "Version"; - } - return name; }//}}} //{{{ getRowCount() - public int getRowCount() { return m_pluginNames.size(); }//}}} //{{{ getValueAt() - public Object getValueAt(int rowIndex, int columnIndex) { String value = null; JARClassLoader loader = jsXe.getPluginLoader(); - if (columnIndex == 0) { - value = loader.getPluginProperty(m_pluginNames.get(rowIndex).toString(), JARClassLoader.PLUGIN_HUMAN_READABLE_NAME); + switch (columnIndex) { + case 0: + return loader.getPluginProperty(m_pluginNames.get(rowIndex).toString(), JARClassLoader.PLUGIN_HUMAN_READABLE_NAME); + case 1: + return loader.getPluginProperty(m_pluginNames.get(rowIndex).toString(), JARClassLoader.PLUGIN_VERSION); + case 2: + ActionPlugin plugin = loader.getPlugin(m_pluginNames.get(rowIndex).toString()); + if (plugin instanceof ActionPlugin.Broken) { + return Messages.getMessage("Plugin.Manager.Broken.Status"); + } else { + return Messages.getMessage("Plugin.Manager.Loaded.Status"); + } + default: + throw new Error("Column out of range"); } - if (columnIndex == 1) { - value = loader.getPluginProperty(m_pluginNames.get(rowIndex).toString(), JARClassLoader.PLUGIN_VERSION); - } - return value; }//}}} //{{{ isCellEditable() - public boolean isCellEditable(int rowIndex, int columnIndex) { return false; }//}}} @@ -230,7 +259,6 @@ }//}}} //{{{ setValueAt() - public void setValueAt(Object aValue, int rowIndex, int columnIndex) { // nothing. not supported. }//}}} This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
|
From: <ian...@us...> - 2006-06-22 00:08:45
|
Revision: 974 Author: ian_lewis Date: 2006-06-21 17:08:31 -0700 (Wed, 21 Jun 2006) ViewCVS: http://svn.sourceforge.net/jsxe/?rev=974&view=rev Log Message: ----------- Added the new menu spill over option Modified Paths: -------------- trunk/jsxe/Changelog trunk/jsxe/messages/messages.en trunk/jsxe/src/net/sourceforge/jsxe/gui/TabbedView.java trunk/jsxe/src/net/sourceforge/jsxe/gui/menu/EnhancedMenu.java trunk/jsxe/src/net/sourceforge/jsxe/options/GeneralOptionPane.java trunk/jsxe/src/net/sourceforge/jsxe/properties Modified: trunk/jsxe/Changelog =================================================================== --- trunk/jsxe/Changelog 2006-06-21 21:14:04 UTC (rev 973) +++ trunk/jsxe/Changelog 2006-06-22 00:08:31 UTC (rev 974) @@ -2,6 +2,8 @@ * Moved EnhancedMenu to it's own package. I will be creating a new menu class that is specially designed for jsXe's LocalizedActions + * Created a new option for how many items can be in menus before they spill + over. 06/20/2006 Ian Lewis <Ian...@me...> Modified: trunk/jsxe/messages/messages.en =================================================================== --- trunk/jsxe/messages/messages.en 2006-06-21 21:14:04 UTC (rev 973) +++ trunk/jsxe/messages/messages.en 2006-06-22 00:08:31 UTC (rev 974) @@ -66,7 +66,9 @@ Global.Options.network-cache=Ask first, then cache remote files Global.Options.network-always=Always download without asking Global.Options.network=DTD and schema downloading: +Global.Options.Menu.Spill.Over=Number of items before menus spill over + Shortcuts.Options.Title=Shortcuts #}}} Modified: trunk/jsxe/src/net/sourceforge/jsxe/gui/TabbedView.java =================================================================== --- trunk/jsxe/src/net/sourceforge/jsxe/gui/TabbedView.java 2006-06-21 21:14:04 UTC (rev 973) +++ trunk/jsxe/src/net/sourceforge/jsxe/gui/TabbedView.java 2006-06-22 00:08:31 UTC (rev 974) @@ -399,7 +399,6 @@ }//}}} //{{{ updateRecentFilesMenu() - private void updateRecentFilesMenu() { /* TODO: Make this more efficient @@ -501,7 +500,7 @@ m_fileMenu.add( menuItem ); //Add recent files menu - m_recentFilesMenu = new EnhancedMenu(Messages.getMessage("File.Recent"), 20); + m_recentFilesMenu = new EnhancedMenu(Messages.getMessage("File.Recent"), jsXe.getIntegerProperty("menu.spill.over", 20)); m_fileMenu.add(m_recentFilesMenu); m_fileMenu.addSeparator(); Modified: trunk/jsxe/src/net/sourceforge/jsxe/gui/menu/EnhancedMenu.java =================================================================== --- trunk/jsxe/src/net/sourceforge/jsxe/gui/menu/EnhancedMenu.java 2006-06-21 21:14:04 UTC (rev 973) +++ trunk/jsxe/src/net/sourceforge/jsxe/gui/menu/EnhancedMenu.java 2006-06-22 00:08:31 UTC (rev 974) @@ -28,6 +28,7 @@ //{{{ jsXe classes import net.sourceforge.jsxe.gui.Messages; +import net.sourceforge.jsxe.EBListener; //}}} //{{{ Java classes @@ -46,7 +47,7 @@ * @author Ian Lewis (<a href="mailto:Ian...@me...">Ian...@me...</a>) * @version $Id$ */ -public class EnhancedMenu extends JMenu { +public class EnhancedMenu extends JMenu implements EBListener { //{{{ EnhancedMenu constructor /** Modified: trunk/jsxe/src/net/sourceforge/jsxe/options/GeneralOptionPane.java =================================================================== --- trunk/jsxe/src/net/sourceforge/jsxe/options/GeneralOptionPane.java 2006-06-21 21:14:04 UTC (rev 973) +++ trunk/jsxe/src/net/sourceforge/jsxe/options/GeneralOptionPane.java 2006-06-22 00:08:31 UTC (rev 974) @@ -74,6 +74,24 @@ //}}} + //{{{ menu spill over + + int menuSpillOver = jsXe.getIntegerProperty("menu.spill.over", 20); + + Vector sizes2 = new Vector(4); + sizes2.add("10"); + sizes2.add("20"); + sizes2.add("30"); + sizes2.add("40"); + menuSpillOverComboBox = new JComboBox(sizes2); + menuSpillOverComboBox.setEditable(true); + menuSpillOverComboBox.setSelectedItem(Integer.toString(menuSpillOver)); + + addComponent(Messages.getMessage("Global.Options.Menu.Spill.Over"), + menuSpillOverComboBox, + Messages.getMessage("Global.Options.Menu.Spill.Over.ToolTip")); + //}}} + //{{{ network String[] networkValues = { @@ -87,7 +105,8 @@ network.setSelectedIndex(jsXe.getIntegerProperty("xml.cache", 1)); addComponent(Messages.getMessage("Global.Options.network"), - network); + network, + Messages.getMessage("Global.Options.network.ToolTip")); //}}} @@ -96,11 +115,15 @@ //{{{ _save() protected void _save() { try { - //don't need to set dirty, no change to text - jsXe.setProperty("max.recent.files", (new Integer(maxRecentFilesComboBox.getSelectedItem().toString())).toString()); + jsXe.setIntegerProperty("max.recent.files", Integer.parseInt(maxRecentFilesComboBox.getSelectedItem().toString())); } catch (NumberFormatException nfe) { //Bad input, don't save. } + try { + jsXe.setIntegerProperty("menu.spill.over", Integer.parseInt(maxRecentFilesComboBox.getSelectedItem().toString())); + } catch (NumberFormatException nfe) { + //Bad input, don't save. + } jsXe.setIntegerProperty("xml.cache",network.getSelectedIndex()); CatalogManager.propertiesChanged(); }//}}} @@ -111,6 +134,7 @@ }//}}} //{{{ Private Members + private JComboBox menuSpillOverComboBox; private JComboBox maxRecentFilesComboBox; private JComboBox network; //}}} Modified: trunk/jsxe/src/net/sourceforge/jsxe/properties =================================================================== --- trunk/jsxe/src/net/sourceforge/jsxe/properties 2006-06-21 21:14:04 UTC (rev 973) +++ trunk/jsxe/src/net/sourceforge/jsxe/properties 2006-06-22 00:08:31 UTC (rev 974) @@ -5,6 +5,7 @@ # :folding=explicit:collapseFolds=1: max.recent.files=20 +menu.spill.over=20 # Enable network operations xml.network=true 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:35:46
|
Revision: 976 Author: ian_lewis Date: 2006-06-23 12:35:33 -0700 (Fri, 23 Jun 2006) ViewCVS: http://svn.sourceforge.net/jsxe/?rev=976&view=rev Log Message: ----------- Added back rudimentary key bindings Modified Paths: -------------- trunk/jsxe/Changelog trunk/jsxe/src/net/sourceforge/jsxe/ActionManager.java trunk/jsxe/src/net/sourceforge/jsxe/action/FileCloseAction.java trunk/jsxe/src/net/sourceforge/jsxe/action/FileExitAction.java trunk/jsxe/src/net/sourceforge/jsxe/action/FileNewAction.java trunk/jsxe/src/net/sourceforge/jsxe/action/FileOpenAction.java trunk/jsxe/src/net/sourceforge/jsxe/action/FileSaveAction.java trunk/jsxe/src/net/sourceforge/jsxe/gui/TabbedView.java trunk/jsxe/src/net/sourceforge/jsxe/gui/menu/EnhancedMenu.java trunk/jsxe/src/net/sourceforge/jsxe/properties Modified: trunk/jsxe/Changelog =================================================================== --- trunk/jsxe/Changelog 2006-06-23 19:13:40 UTC (rev 975) +++ trunk/jsxe/Changelog 2006-06-23 19:35:33 UTC (rev 976) @@ -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/21/2006 Ian Lewis <Ian...@me...> * Moved EnhancedMenu to it's own package. I will be creating a new menu Modified: trunk/jsxe/src/net/sourceforge/jsxe/ActionManager.java =================================================================== --- trunk/jsxe/src/net/sourceforge/jsxe/ActionManager.java 2006-06-23 19:13:40 UTC (rev 975) +++ trunk/jsxe/src/net/sourceforge/jsxe/ActionManager.java 2006-06-23 19:35:33 UTC (rev 976) @@ -87,21 +87,23 @@ * @param name the name of the action. */ public static Action getAction(String name) { + Log.log(Log.NOTICE, ActionManager.class, "Loading key bindings."); Action action = (Action)m_actionMap.get(name); if (action == null) { LocalizedAction editAction = getLocalizedAction(name); if (editAction != null) { action = new Wrapper(name); - if (editAction == null) { - String dispName = editAction.getLabel(); - String keyBinding = jsXe.getProperty(name+".shortcut"); - - action.putValue(Action.NAME, dispName); - - if (keyBinding != null) { - action.putValue(Action.ACCELERATOR_KEY, keyBinding); - } + String dispName = editAction.getLabel(); + //TODO: add method for setting menu mnemonic from label + + String keyBinding = jsXe.getProperty(name+".shortcut"); + + action.putValue(Action.NAME, dispName); + + if (keyBinding != null) { + action.putValue(Action.ACCELERATOR_KEY, KeyStroke.getKeyStroke(keyBinding)); + Log.log(Log.NOTICE, ActionManager.class, "Loaded key binding for "+name+": "+keyBinding); } m_actionMap.put(name, action); @@ -149,7 +151,11 @@ if (msg.getKey().endsWith(".shortcut")) { String actionName = msg.getKey().substring(0, msg.getKey().lastIndexOf(".")); String keyBinding = jsXe.getProperty(msg.getKey()); - addKeyBinding(keyBinding, actionName); + if (keyBinding != null) { + addKeyBinding(keyBinding, actionName); + } else { + removeKeyBinding(msg.getOldValue()); + } } } }//}}} @@ -191,6 +197,8 @@ if (action != null && keyBinding != null) { Action wrapper = getAction(action.getName()); m_keyBindingMap.put(keyBinding,wrapper); + + //need to do this so that the accelerator key is rendered on menu items wrapper.putValue(Action.ACCELERATOR_KEY, KeyStroke.getKeyStroke(keyBinding)); } }//}}} Modified: trunk/jsxe/src/net/sourceforge/jsxe/action/FileCloseAction.java =================================================================== --- trunk/jsxe/src/net/sourceforge/jsxe/action/FileCloseAction.java 2006-06-23 19:13:40 UTC (rev 975) +++ trunk/jsxe/src/net/sourceforge/jsxe/action/FileCloseAction.java 2006-06-23 19:35:33 UTC (rev 976) @@ -59,7 +59,6 @@ //{{{ FileCloseAction constructor public FileCloseAction() { super("close-file"); - // putValue(Action.ACCELERATOR_KEY,KeyStroke.getKeyStroke("ctrl W")); }//}}} //{{{ actionPerformed() Modified: trunk/jsxe/src/net/sourceforge/jsxe/action/FileExitAction.java =================================================================== --- trunk/jsxe/src/net/sourceforge/jsxe/action/FileExitAction.java 2006-06-23 19:13:40 UTC (rev 975) +++ trunk/jsxe/src/net/sourceforge/jsxe/action/FileExitAction.java 2006-06-23 19:35:33 UTC (rev 976) @@ -50,7 +50,6 @@ //{{{ FileExitAction constructor public FileExitAction() { super("exit"); - // putValue(Action.ACCELERATOR_KEY,KeyStroke.getKeyStroke("ctrl Q")); }//}}} //{{{ invoke() Modified: trunk/jsxe/src/net/sourceforge/jsxe/action/FileNewAction.java =================================================================== --- trunk/jsxe/src/net/sourceforge/jsxe/action/FileNewAction.java 2006-06-23 19:13:40 UTC (rev 975) +++ trunk/jsxe/src/net/sourceforge/jsxe/action/FileNewAction.java 2006-06-23 19:35:33 UTC (rev 976) @@ -55,7 +55,6 @@ //{{{ FileNewAction constructor public FileNewAction() { super("new-file"); - // putValue(Action.ACCELERATOR_KEY,KeyStroke.getKeyStroke("ctrl N")); }//}}} //{{{ invoke() Modified: trunk/jsxe/src/net/sourceforge/jsxe/action/FileOpenAction.java =================================================================== --- trunk/jsxe/src/net/sourceforge/jsxe/action/FileOpenAction.java 2006-06-23 19:13:40 UTC (rev 975) +++ trunk/jsxe/src/net/sourceforge/jsxe/action/FileOpenAction.java 2006-06-23 19:35:33 UTC (rev 976) @@ -58,7 +58,6 @@ //{{{ FileOpenAction constructor public FileOpenAction() { super("open-file"); - // putValue(Action.ACCELERATOR_KEY,KeyStroke.getKeyStroke("ctrl O")); }//}}} //{{{ invoke() Modified: trunk/jsxe/src/net/sourceforge/jsxe/action/FileSaveAction.java =================================================================== --- trunk/jsxe/src/net/sourceforge/jsxe/action/FileSaveAction.java 2006-06-23 19:13:40 UTC (rev 975) +++ trunk/jsxe/src/net/sourceforge/jsxe/action/FileSaveAction.java 2006-06-23 19:35:33 UTC (rev 976) @@ -59,7 +59,6 @@ //{{{ FileSaveAction constructor public FileSaveAction() { super("save-file"); - // putValue(Action.ACCELERATOR_KEY,KeyStroke.getKeyStroke("ctrl S")); }//}}} //{{{ invoke() Modified: trunk/jsxe/src/net/sourceforge/jsxe/gui/TabbedView.java =================================================================== --- trunk/jsxe/src/net/sourceforge/jsxe/gui/TabbedView.java 2006-06-23 19:13:40 UTC (rev 975) +++ trunk/jsxe/src/net/sourceforge/jsxe/gui/TabbedView.java 2006-06-23 19:35:33 UTC (rev 976) @@ -326,6 +326,11 @@ protected void processKeyEvent(KeyEvent e) { //TODO: process shortcuts Log.log(Log.DEBUG, this, e.toString()); + /* + TODO: We should process all key events here instead of having Swing + process them. Since we don't know which would be added to menus and + which aren't. + */ super.processKeyEvent(e); }//}}} Modified: trunk/jsxe/src/net/sourceforge/jsxe/gui/menu/EnhancedMenu.java =================================================================== --- trunk/jsxe/src/net/sourceforge/jsxe/gui/menu/EnhancedMenu.java 2006-06-23 19:13:40 UTC (rev 975) +++ trunk/jsxe/src/net/sourceforge/jsxe/gui/menu/EnhancedMenu.java 2006-06-23 19:35:33 UTC (rev 976) @@ -47,7 +47,7 @@ * @author Ian Lewis (<a href="mailto:Ian...@me...">Ian...@me...</a>) * @version $Id$ */ -public class EnhancedMenu extends JMenu implements EBListener { +public class EnhancedMenu extends JMenu { //{{{ EnhancedMenu constructor /** Modified: trunk/jsxe/src/net/sourceforge/jsxe/properties =================================================================== --- trunk/jsxe/src/net/sourceforge/jsxe/properties 2006-06-23 19:13:40 UTC (rev 975) +++ trunk/jsxe/src/net/sourceforge/jsxe/properties 2006-06-23 19:35:33 UTC (rev 976) @@ -51,4 +51,10 @@ metal.secondary.fontstyle=0 #}}} - +#{{{ Default key bindings +open-file.shortcut=ctrl O +exit.shortcut=ctrl Q +close-file.shortcut=ctrl W +new-file.shortcut=ctrl N +save-file.shortcut=ctrl S +#}}} 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:30:00
|
Revision: 966 Author: ian_lewis Date: 2006-06-20 12:29:38 -0700 (Tue, 20 Jun 2006) ViewCVS: http://svn.sourceforge.net/jsxe/?rev=966&view=rev Log Message: ----------- Updated actions in jsXe to be managed by the ActionManager class Modified Paths: -------------- trunk/jsxe/Changelog trunk/jsxe/messages/messages.en trunk/jsxe/src/net/sourceforge/jsxe/ActionPlugin.java trunk/jsxe/src/net/sourceforge/jsxe/ActionSet.java trunk/jsxe/src/net/sourceforge/jsxe/action/ActivityLogAction.java trunk/jsxe/src/net/sourceforge/jsxe/action/DocumentOptionsAction.java trunk/jsxe/src/net/sourceforge/jsxe/action/FileCloseAction.java trunk/jsxe/src/net/sourceforge/jsxe/action/FileCloseAllAction.java trunk/jsxe/src/net/sourceforge/jsxe/action/FileExitAction.java trunk/jsxe/src/net/sourceforge/jsxe/action/FileNewAction.java trunk/jsxe/src/net/sourceforge/jsxe/action/FileOpenAction.java trunk/jsxe/src/net/sourceforge/jsxe/action/FileReloadAction.java trunk/jsxe/src/net/sourceforge/jsxe/action/FileSaveAction.java trunk/jsxe/src/net/sourceforge/jsxe/action/FileSaveAsAction.java trunk/jsxe/src/net/sourceforge/jsxe/action/OpenRecentFileAction.java trunk/jsxe/src/net/sourceforge/jsxe/action/ToolsOptionsAction.java trunk/jsxe/src/net/sourceforge/jsxe/action/ToolsPluginManagerAction.java trunk/jsxe/src/net/sourceforge/jsxe/action/ValidationErrorsAction.java trunk/jsxe/src/net/sourceforge/jsxe/gui/TabbedView.java trunk/jsxe/src/net/sourceforge/jsxe/gui/jsxeAboutDialog.java trunk/jsxe/src/net/sourceforge/jsxe/jsXe.java trunk/jsxe/src/net/sourceforge/jsxe/util/MiscUtilities.java Added Paths: ----------- trunk/jsxe/src/net/sourceforge/jsxe/ActionManager.java trunk/jsxe/src/net/sourceforge/jsxe/LocalizedAction.java Removed Paths: ------------- trunk/jsxe/src/net/sourceforge/jsxe/InputManager.java Modified: trunk/jsxe/Changelog =================================================================== --- trunk/jsxe/Changelog 2006-06-15 21:52:24 UTC (rev 965) +++ trunk/jsxe/Changelog 2006-06-20 19:29:38 UTC (rev 966) @@ -1,3 +1,10 @@ +06/20/2006 Ian Lewis <Ian...@me...> + + * Updated actions in jsXe so that actions can be easily localized and + so that they can be assigned shortcuts. Future actions that are registered + with jsXe will extend this class. The ActionManager now manages ActionSets + and key bindings within jsXe. + 06/15/2006 Ian Lewis <Ian...@me...> * Added a new Status column to the Plugin Manager dialog Modified: trunk/jsxe/messages/messages.en =================================================================== --- trunk/jsxe/messages/messages.en 2006-06-15 21:52:24 UTC (rev 965) +++ trunk/jsxe/messages/messages.en 2006-06-20 19:29:38 UTC (rev 966) @@ -106,24 +106,24 @@ Help.Menu=Help #{{{ File Menu Items -File.New=New -File.Open=Open... +new-file.label=New +open-file.label=Open... File.Recent=Recent Files File.Recent.None=No Recent Files -File.Save=Save -File.SaveAs=Save As... -File.Reload=Reload +save-file.label=Save +save-as.label=Save As... +reload-file.label=Reload File.Recent=Recent Files -File.Close=Close -File.CloseAll=Close All -File.Exit=Exit +close-file.label=Close +close-all.label=Close All +exit.label=Exit #}}} -Tools.Options=Global Options... -Tools.Document.Options=Document Options... -Tools.Plugin=Plugin Manager... -Tools.ValidationErrors=Validation Errors... -Help.About=About jsXe... +general-options.label=Global Options... +document-options.label=Document Options... +plugin-manager.label=Plugin Manager... +validation-errors.label=Validation Errors... +about-jsxe.label=About jsXe... #}}} #{{{ Messages @@ -219,7 +219,7 @@ #}}} #{{{ Activity Log Dialog -ActivityLogDialog.Open = Activity Log +activity-log.label = Activity Log ActivityLogDialog.Dialog.Title = Activity Log ActivityLogDialog.Dialog.Message = Activity Log contents: #}}} Copied: trunk/jsxe/src/net/sourceforge/jsxe/ActionManager.java (from rev 959, trunk/jsxe/src/net/sourceforge/jsxe/InputManager.java) =================================================================== --- trunk/jsxe/src/net/sourceforge/jsxe/ActionManager.java (rev 0) +++ trunk/jsxe/src/net/sourceforge/jsxe/ActionManager.java 2006-06-20 19:29:38 UTC (rev 966) @@ -0,0 +1,283 @@ +/* +ActionManager.java +:tabSize=4:indentSize=4:noTabs=true: +:folding=explicit:collapseFolds=1: + +jsXe is the Java Simple XML Editor +jsXe is a gui application that creates a tree view of an XML document. +The user can then edit this tree and the content in the tree. + +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 net.sourceforge.jsxe; + +//{{{ imports +import net.sourceforge.jsxe.gui.TabbedView; +import net.sourceforge.jsxe.gui.Messages; +import net.sourceforge.jsxe.util.Log; +import net.sourceforge.jsxe.util.MiscUtilities; +import net.sourceforge.jsxe.msg.PropertyChanged; +import javax.swing.Action; +import javax.swing.AbstractAction; +import javax.swing.KeyStroke; +import java.util.HashMap; +import java.util.Iterator; +import java.util.ArrayList; +import java.awt.event.ActionEvent; +//}}} + +/** + * The ActionManager handles key bindings within jsXe. + * + * @author Ian Lewis (<a href="mailto:Ian...@me...">Ian...@me...</a>) + * @version $Id$ + * @since jsXe 0.5 pre1 + */ +public class ActionManager { + + //{{{ addActionSet() + /** + * Adds a set of actions to the jsXe's pool of action sets. + * This allows action sets from installed plugins to be added + * and retrieved via jsXe's pool of actions. + * @param set the action set to add + */ + public static void addActionSet(ActionSet set) { + m_actionSets.add(set); + }//}}} + + //{{{ getLocalizedAction() + /** + * Gets the LocalizedAction set with the given name + * @param the name of the action set. + * @return the action set that matches the name, or null if none match. + */ + public static LocalizedAction getLocalizedAction(String name) { + for (int i = 0; i < m_actionSets.size(); i++) { + LocalizedAction action = ((ActionSet)m_actionSets.get(i)).getAction(name); + if (action != null) { + return action; + } + } + Log.log(Log.WARNING,ActionManager.class,"Unknown action: "+ name); + return null; + }//}}} + + //{{{ getAction() + /** + * Gets a true action for the LocalizedAction with the given name. This can be + * used in menus and toobars etc. + * @param name the name of the action. + */ + public static Action getAction(String name) { + Action action = (Action)m_actionMap.get(name); + if (action == null) { + LocalizedAction editAction = getLocalizedAction(name); + if (editAction != null) { + action = new Wrapper(name); + + if (editAction == null) { + String dispName = editAction.getLabel(); + String keyBinding = jsXe.getProperty(name+".shortcut"); + + action.putValue(Action.NAME, dispName); + + if (keyBinding != null) { + action.putValue(Action.ACCELERATOR_KEY, keyBinding); + } + } + + m_actionMap.put(name, action); + } else { + Log.log(Log.WARNING,ActionManager.class,"Unknown action: "+ name); + } + } + return action; + }//}}} + + //{{{ getActionSets() + /** + * Gets all action sets that have been registered with jsXe + * @return an ArrayList of ActionSet objects + */ + public static ArrayList getActionSets() { + return m_actionSets; + }//}}} + + //{{{ invokeAction() + /** + * Invokes the action with the given name. + * @param name the internal name of the action + */ + public static void invokeAction(String name, ActionEvent evt) { + invokeAction(getLocalizedAction(name), evt); + }//}}} + + //{{{ initKeyBindings() + /** + * Initialized the key bindings for jsXe. This method is called + * at startup after plugins are loaded. Subsequent calls will + * do nothing. + */ + public static void initKeyBindings() { + if (!initialized) { + + //Add EditBus Listener to update key bindings when properties are changed + EditBus.addToBus(new EBListener() { + + //{{{ handleMessage() + public void handleMessage(EBMessage message) { + if (message instanceof PropertyChanged) { + PropertyChanged msg = (PropertyChanged)message; + if (msg.getKey().endsWith(".shortcut")) { + String actionName = msg.getKey().substring(0, msg.getKey().lastIndexOf(".")); + String keyBinding = jsXe.getProperty(msg.getKey()); + addKeyBinding(keyBinding, actionName); + } + } + }//}}} + + }); + + Iterator itr = m_actionSets.iterator(); + while (itr.hasNext()) { + ActionSet set = (ActionSet)itr.next(); + LocalizedAction[] actions = set.getActions(); + for (int i=0; i<actions.length; i++) { + String actionName = actions[i].getName(); + String keyBinding = jsXe.getProperty(actionName+".shortcut"); + addKeyBinding(keyBinding, actions[i]); + } + } + + initialized=true; + } + }//}}} + + //{{{ addKeyBinding() + /** + * Adds a key binding to jsXe. + * @param keyBinding The key binding + * @param action The action name + */ + public static void addKeyBinding(String keyBinding, String action) { + addKeyBinding(keyBinding, getLocalizedAction(action)); + }//}}} + + //{{{ addKeyBinding() + /** + * Adds a key binding to this input handler. + * @param keyBinding The key binding + * @param action The action + */ + public static void addKeyBinding(String keyBinding, LocalizedAction action) { + if (action != null && keyBinding != null) { + Action wrapper = getAction(action.getName()); + m_keyBindingMap.put(keyBinding,wrapper); + wrapper.putValue(Action.ACCELERATOR_KEY, KeyStroke.getKeyStroke(keyBinding)); + } + }//}}} + + //{{{ removeKeyBinding() + /** + * Removes a key binding. + * @param keyBinding The key binding + */ + public static void removeKeyBinding(String keyBinding) { + Action action = (Action)m_keyBindingMap.get(keyBinding); + if (action != null) { + action.putValue(Action.ACCELERATOR_KEY, null); + m_keyBindingMap.remove(keyBinding); + } + }//}}} + + //{{{ removeAllKeyBindings() + /** + * Removes all key bindings. + */ + public static void removeAllKeyBindings() { + Iterator itr = m_keyBindingMap.keySet().iterator(); + while (itr.hasNext()) { + removeKeyBinding(itr.next().toString()); + } + }//}}} + + //{{{ Wrapper class + /** + * The Wrapper class wraps LocalizedActions so they can be invoked + * through Swing via the ActionListener interface. + */ + public static class Wrapper extends AbstractAction { + + //{{{ Wrapper constructor + /** + * Creates a new wrapper action. + * @param name the name of the registered action to wrap + */ + public Wrapper(String name) { + this(getLocalizedAction(name)); + }//}}} + + //{{{ Wrapper constructor + /** + * Creates a new wrapper action. + * @param name the name of the registered action to wrap + */ + public Wrapper(LocalizedAction action) { + m_action = action; + putValue(AbstractAction.NAME, action.getLabel()); + }//}}} + + //{{{ actionPerformed() + public void actionPerformed(ActionEvent evt) { + invokeAction(m_action, evt); + }//}}} + + //{{{ Private members + private LocalizedAction m_action; + //}}} + + }//}}} + + //{{{ Private Members + /** + * This is a key binding to Wrapper mapping. + */ + private static HashMap m_keyBindingMap = new HashMap(); + /** + * This is an name to Wrapper mapping. + */ + private static HashMap m_actionMap = new HashMap(); + private static ArrayList m_actionSets = new ArrayList(); + + private static boolean initialized = false; + + //{{{ invokeAction() + private static void invokeAction(LocalizedAction action, ActionEvent evt) { + if (action != null) { + action.invoke((TabbedView)MiscUtilities.getComponentParent((java.awt.Component)evt.getSource(), TabbedView.class), evt); + } + }//}}} + + //{{{ ActionManager constructor + private ActionManager() {}//}}} + + //}}} +} Modified: trunk/jsxe/src/net/sourceforge/jsxe/ActionPlugin.java =================================================================== --- trunk/jsxe/src/net/sourceforge/jsxe/ActionPlugin.java 2006-06-15 21:52:24 UTC (rev 965) +++ trunk/jsxe/src/net/sourceforge/jsxe/ActionPlugin.java 2006-06-20 19:29:38 UTC (rev 966) @@ -109,8 +109,8 @@ * @param name the name of the action * @param action the action itself */ - protected void addAction(String name, Action action) { - m_actionSet.addAction(name, action); + protected void addAction(LocalizedAction action) { + m_actionSet.addAction(action); }//}}} //{{{ getActionSet() Modified: trunk/jsxe/src/net/sourceforge/jsxe/ActionSet.java =================================================================== --- trunk/jsxe/src/net/sourceforge/jsxe/ActionSet.java 2006-06-15 21:52:24 UTC (rev 965) +++ trunk/jsxe/src/net/sourceforge/jsxe/ActionSet.java 2006-06-20 19:29:38 UTC (rev 966) @@ -26,7 +26,6 @@ package net.sourceforge.jsxe; import java.util.*; -import javax.swing.Action; /** * A set of actions. @@ -75,23 +74,13 @@ //{{{ addAction() /** - * Adds an action to the action set. - * @param name the internal name for the action - * @param action The action - * @deprecated Use EditActions instead - */ - public void addAction(String name, Action action) { - actions.put(name,action); - }//}}} - - //{{{ addAction() - /** * Adds an action to the action set. The action can - * be retrieved via the INTERNAL_NAME of the EditAction. + * be retrieved via the <code>getName()</code> method of + * the LocalizedAction. * @param action The action */ - public void addAction(EditAction action) { - actions.put(action.getProperty(EditAction.INTERNAL_NAME),action); + public void addAction(LocalizedAction action) { + actions.put(action.getName(),action); }//}}} //{{{ removeAction() @@ -113,11 +102,11 @@ //{{{ getAction() /** - * Returns an action with the specified name. + * Returns the action with the specified name. * @param name The action name */ - public Action getAction(String name) { - return (Action)actions.get(name); + public LocalizedAction getAction(String name) { + return (LocalizedAction)actions.get(name); }//}}} //{{{ getActionCount() @@ -132,12 +121,12 @@ /** * Returns an array of all actions in this action set. */ - public Action[] getActions() { - Action[] retVal = new Action[actions.size()]; + public LocalizedAction[] getActions() { + LocalizedAction[] retVal = new LocalizedAction[actions.size()]; Enumeration elements = actions.elements(); int i = 0; while(elements.hasMoreElements()) { - retVal[i++] = (Action)elements.nextElement(); + retVal[i++] = (LocalizedAction)elements.nextElement(); } return retVal; }//}}} @@ -147,7 +136,7 @@ * Returns if this action set contains the specified action. * @param action The action */ - public boolean contains(Action action) { + public boolean contains(LocalizedAction action) { return actions.contains(action); }//}}} Deleted: trunk/jsxe/src/net/sourceforge/jsxe/InputManager.java =================================================================== --- trunk/jsxe/src/net/sourceforge/jsxe/InputManager.java 2006-06-15 21:52:24 UTC (rev 965) +++ trunk/jsxe/src/net/sourceforge/jsxe/InputManager.java 2006-06-20 19:29:38 UTC (rev 966) @@ -1,104 +0,0 @@ -/* -InputManager.java -:tabSize=4:indentSize=4:noTabs=true: -:folding=explicit:collapseFolds=1: - -jsXe is the Java Simple XML Editor -jsXe is a gui application that creates a tree view of an XML document. -The user can then edit this tree and the content in the tree. - -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 net.sourceforge.jsxe; - -//{{{ imports -import javax.swing.Action; -import javax.swing.KeyStroke; -import java.util.HashMap; -import java.util.Iterator; -//}}} - -/** - * The InputManager handles the key bindings for Actions within jsXe. - * - * @author Ian Lewis (<a href="mailto:Ian...@me...">Ian...@me...</a>) - * @version $Id$ - * @since jsXe 0.5 pre1 - */ -public class InputManager { - - //{{{ addKeyBinding() method - /** - * Adds a key binding to jsXe. - * @param keyBinding The key binding - * @param action The action - */ - public static void addKeyBinding(String keyBinding, String action) { - addKeyBinding(keyBinding, jsXe.getAction(action)); - }//}}} - - //{{{ addKeyBinding() method - /** - * Adds a key binding to this input handler. - * @param keyBinding The key binding - * @param action The action - */ - public static void addKeyBinding(String keyBinding, Action action) { - if (action != null) { - m_keyBindingMap.put(keyBinding, action); - action.putValue(Action.ACCELERATOR_KEY,KeyStroke.getKeyStroke(keyBinding)); - jsXe.setProperty(action.getValue(Action.NAME)+".shortcut", keyBinding); - } - }//}}} - - //{{{ removeKeyBinding() method - /** - * Removes a key binding. - * @param keyBinding The key binding - */ - public static void removeKeyBinding(String keyBinding) { - Action action = (Action)m_keyBindingMap.get(keyBinding); - if (action != null) { - action.putValue(Action.ACCELERATOR_KEY, null); - m_keyBindingMap.remove(keyBinding); - } - }//}}} - - //{{{ removeAllKeyBindings() method - /** - * Removes all key bindings. - */ - public static void removeAllKeyBindings() { - Iterator itr = m_keyBindingMap.keySet().iterator(); - while (itr.hasNext()) { - removeKeyBinding(itr.next().toString()); - } - m_keyBindingMap = new HashMap(); - }//}}} - - //{{{ Private Members - - //{{{ InputManager constructor - private InputManager() {}//}}} - - private static HashMap m_keyBindingMap = new HashMap(); - - //}}} -} Added: trunk/jsxe/src/net/sourceforge/jsxe/LocalizedAction.java =================================================================== --- trunk/jsxe/src/net/sourceforge/jsxe/LocalizedAction.java (rev 0) +++ trunk/jsxe/src/net/sourceforge/jsxe/LocalizedAction.java 2006-06-20 19:29:38 UTC (rev 966) @@ -0,0 +1,121 @@ +/* +LocalizedAction.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 net.sourceforge.jsxe; + +//{{{ imports +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.util.Properties; +import net.sourceforge.jsxe.gui.TabbedView; +import net.sourceforge.jsxe.gui.Messages; +import net.sourceforge.jsxe.util.Log; +import net.sourceforge.jsxe.util.MiscUtilities; +//}}} + +/** + * An action that can be used by jsXe. These actions are registered + * with jsXe through ActionSets. These ActionSets can be registered with + * jsXe by plugins. Once an LocalizedAction is included in an ActionSet and + * registered with jsXe via the <code>addActionSet()</code> method, + * key bindings can be associated to the action via the InputManager. + * + * @author Ian Lewis (<a href="mailto:Ian...@me...">Ian...@me...</a>) + * @version $Id$ + * @see jsXe + * @see ActionSet + * @see InputManager + * @since jsXe 0.5 pre1 + */ +public abstract class LocalizedAction { + + // {{{ Public static members + /** + * The internal name of the action used for retrieval from + * <code>jsXe.getAction(String)</code> and for storing properties related + * to the action. + */ + public static final String INTERNAL_NAME = "internal-name"; + /** + * The message name of the action used to retrieve the localized + * human readable text for the action. The text is retrieved from + * the net.sourceforge.jsxe.Messages class. The text determines the + * menu key mnemonic as well. + */ + public static final String MESSAGE_NAME = "message-name"; + /** + * As an alternative to the MESSAGE_NAME an actual name can be used. + * This should only be used in the case that the action's name is + * not locale specific, such as a file name or url. + */ + public static final String NAME = "name"; + /** + * The message name for the localized tooltip message that + * is associated with this action. + */ + public static final String TOOLTIP_MESSAGE_NAME = "tooltip-message-name"; + //}}} + + //{{{ LocalizedAction constructor + /** + * Creates a new LocalizedAction that can be used with jsXe. + * @param name the internal name of the action. + */ + public LocalizedAction(String name) { + m_name = name; + }//}}} + + //{{{ invoke() + /** + * The method that is run when the action is invoked. + * @param view the view that invoked the action. + * @param evt the ActionEvent for this event. + */ + public abstract void invoke(TabbedView view, ActionEvent evt);//}}} + + //{{{ getName() + /** + * Gets the internal name for this action. + * @ + */ + public String getName() { + return m_name; + }//}}} + + //{{{ getLabel() + /** + * Gets the human readable localized label for this action. + * This returns the value of the property named by + * {@link #getName()} suffixed with <code>.label</code>. + * @see net.sourceforge.jsxe.gui.Messages + * @return the localized label + */ + public String getLabel() { + return Messages.getMessage(m_name+".label"); + }//}}} + + //{{{ Private members + private String m_name; + //}}} +} Property changes on: trunk/jsxe/src/net/sourceforge/jsxe/LocalizedAction.java ___________________________________________________________________ Name: svn:executable + * Modified: trunk/jsxe/src/net/sourceforge/jsxe/action/ActivityLogAction.java =================================================================== --- trunk/jsxe/src/net/sourceforge/jsxe/action/ActivityLogAction.java 2006-06-15 21:52:24 UTC (rev 965) +++ trunk/jsxe/src/net/sourceforge/jsxe/action/ActivityLogAction.java 2006-06-20 19:29:38 UTC (rev 966) @@ -4,6 +4,7 @@ :folding=explicit:collapseFolds=1: Copyright (C) 2005 Trish Harnett (tri...@me...) +Portions 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 @@ -25,26 +26,14 @@ package net.sourceforge.jsxe.action; //{{{ imports -/* -All classes are listed explicitly so -it is easy to see which package it -belongs to. -*/ //{{{ jsXe classes -import net.sourceforge.jsxe.gui.Messages; +import net.sourceforge.jsxe.LocalizedAction; import net.sourceforge.jsxe.gui.TabbedView; import net.sourceforge.jsxe.gui.ActivityLogDialog; import net.sourceforge.jsxe.util.Log; //}}} -//{{{ Swing components -import javax.swing.Action; -import javax.swing.AbstractAction; -import javax.swing.JOptionPane; -import javax.swing.KeyStroke; -//}}} - //{{{ AWT components import java.awt.event.ActionEvent; //}}} @@ -56,30 +45,30 @@ * option under the Help Menu * * @author Trish Hartnett + * @author Ian Lewis (<a href="mailto:Ian...@me...">Ian...@me...</a>) * @version $Id$ */ -public class ActivityLogAction extends AbstractAction { - - // {{{ Private members - private TabbedView view; - private ActivityLogDialog dialog = new ActivityLogDialog(view); +public class ActivityLogAction extends LocalizedAction { + + //{{{ Private Members + private ActivityLogDialog m_dialog; //}}} //{{{ ActivityLogAction constructor /** - * @param TabbedView parent view containing the JSXE editor. * Constructor for the ActivityLogActionclass * @since jsXe 0.3pre15 */ - public ActivityLogAction(TabbedView parent) { - putValue(Action.NAME, Messages.getMessage("ActivityLogDialog.Open")); - putValue(Action.MNEMONIC_KEY, new Integer(KeyStroke.getKeyStroke("L").getKeyCode())); - view = parent; + public ActivityLogAction() { + super("activity-log"); }//}}} - //{{{ actionPerformed() - public void actionPerformed(ActionEvent e) { - dialog.refreshContents(); - dialog.setVisible(true); + //{{{ invoke() + public void invoke(TabbedView view, ActionEvent evt) { + if (m_dialog == null) { + m_dialog = new ActivityLogDialog(view); + } + m_dialog.refreshContents(); + m_dialog.setVisible(true); }//}}} } Modified: trunk/jsxe/src/net/sourceforge/jsxe/action/DocumentOptionsAction.java =================================================================== --- trunk/jsxe/src/net/sourceforge/jsxe/action/DocumentOptionsAction.java 2006-06-15 21:52:24 UTC (rev 965) +++ trunk/jsxe/src/net/sourceforge/jsxe/action/DocumentOptionsAction.java 2006-06-20 19:29:38 UTC (rev 966) @@ -25,24 +25,13 @@ package net.sourceforge.jsxe.action; //{{{ imports -/* -All classes are listed explicitly so -it is easy to see which package it -belongs to. -*/ //{{{ jsXe classes +import net.sourceforge.jsxe.LocalizedAction; import net.sourceforge.jsxe.gui.DocumentOptionsDialog; -import net.sourceforge.jsxe.gui.Messages; import net.sourceforge.jsxe.gui.TabbedView; //}}} -//{{{ Swing components -import javax.swing.Action; -import javax.swing.AbstractAction; -import javax.swing.KeyStroke; -//}}} - //{{{ AWT components import java.awt.event.ActionEvent; //}}} @@ -55,24 +44,16 @@ * @author Ian Lewis (<a href="mailto:Ian...@me...">Ian...@me...</a>) * @version $Id$ */ -public class DocumentOptionsAction extends AbstractAction { +public class DocumentOptionsAction extends LocalizedAction { //{{{ DocumentOptionsAction constructor - - public DocumentOptionsAction(TabbedView parent) { - //putValue(Action.NAME, "Options..."); - putValue(Action.NAME, Messages.getMessage("Tools.Document.Options")); - putValue(Action.MNEMONIC_KEY, new Integer(KeyStroke.getKeyStroke("D").getKeyCode())); - view = parent; + public DocumentOptionsAction() { + super("document-options"); }//}}} - //{{{ actionPerformed() - - public void actionPerformed(ActionEvent e) { +... [truncated message content] |
|
From: <ian...@us...> - 2006-06-27 19:59:23
|
Revision: 983 Author: ian_lewis Date: 2006-06-27 12:59:04 -0700 (Tue, 27 Jun 2006) ViewCVS: http://svn.sourceforge.net/jsxe/?rev=983&view=rev Log Message: ----------- Updated several classes for supporting shortcuts Modified Paths: -------------- trunk/jsxe/Changelog trunk/jsxe/src/net/sourceforge/jsxe/ActionManager.java trunk/jsxe/src/net/sourceforge/jsxe/ActionSet.java trunk/jsxe/src/net/sourceforge/jsxe/OperatingSystem.java trunk/jsxe/src/net/sourceforge/jsxe/gui/GridPanel.java trunk/jsxe/src/net/sourceforge/jsxe/gui/Messages.java trunk/jsxe/src/net/sourceforge/jsxe/options/ShortcutsOptionPane.java trunk/jsxe/src/net/sourceforge/jsxe/util/MiscUtilities.java Added Paths: ----------- trunk/jsxe/src/net/sourceforge/jsxe/gui/GUIUtilities.java trunk/jsxe/src/net/sourceforge/jsxe/gui/GrabKeyDialog.java Modified: trunk/jsxe/Changelog =================================================================== --- trunk/jsxe/Changelog 2006-06-25 19:12:04 UTC (rev 982) +++ trunk/jsxe/Changelog 2006-06-27 19:59:04 UTC (rev 983) @@ -1,3 +1,9 @@ +06/27/2006 Ian Lewis <Ian...@me...> + + * Added the GUIUtilities class for handling utility functions in jsXe. + * Added the GrabKeyDialog which will be used to assign shortcuts. + * Updated many classes for supporting shortcuts. + 06/23/2006 Ian Lewis <Ian...@me...> * Added back rudimentary key bindings using Swing Actions so they get Modified: trunk/jsxe/src/net/sourceforge/jsxe/ActionManager.java =================================================================== --- trunk/jsxe/src/net/sourceforge/jsxe/ActionManager.java 2006-06-25 19:12:04 UTC (rev 982) +++ trunk/jsxe/src/net/sourceforge/jsxe/ActionManager.java 2006-06-27 19:59:04 UTC (rev 983) @@ -29,20 +29,34 @@ package net.sourceforge.jsxe; //{{{ imports -import net.sourceforge.jsxe.gui.TabbedView; + +//{{{ jsXe classes import net.sourceforge.jsxe.gui.Messages; +import net.sourceforge.jsxe.gui.GUIUtilities; import net.sourceforge.jsxe.util.Log; import net.sourceforge.jsxe.util.MiscUtilities; import net.sourceforge.jsxe.msg.PropertyChanged; +//}}} + +//{{{ Java classes +import java.util.HashMap; +import java.util.Iterator; +import java.util.ArrayList; +//}}} + +//{{{ Swing classes import javax.swing.Action; import javax.swing.AbstractAction; import javax.swing.KeyStroke; -import java.util.HashMap; -import java.util.Iterator; -import java.util.ArrayList; +//}}} + +//{{{ AWT classes import java.awt.event.ActionEvent; +import java.awt.event.KeyEvent; //}}} +//}}} + /** * The ActionManager handles key bindings within jsXe. * @@ -198,10 +212,11 @@ public static void addKeyBinding(String keyBinding, LocalizedAction action) { if (action != null && keyBinding != null) { Action wrapper = getAction(action.getName()); - m_keyBindingMap.put(keyBinding,wrapper); + KeyStroke key = KeyStroke.getKeyStroke(keyBinding); + m_keyBindingMap.put(key,wrapper); //need to do this so that the accelerator key is rendered on menu items - wrapper.putValue(Action.ACCELERATOR_KEY, KeyStroke.getKeyStroke(keyBinding)); + wrapper.putValue(Action.ACCELERATOR_KEY, key); } }//}}} @@ -211,11 +226,7 @@ * @param keyBinding The key binding */ public static void removeKeyBinding(String keyBinding) { - Action action = (Action)m_keyBindingMap.get(keyBinding); - if (action != null) { - action.putValue(Action.ACCELERATOR_KEY, null); - m_keyBindingMap.remove(keyBinding); - } + removeKeyBinding(KeyStroke.getKeyStroke(keyBinding)); }//}}} //{{{ removeAllKeyBindings() @@ -225,10 +236,20 @@ public static void removeAllKeyBindings() { Iterator itr = m_keyBindingMap.keySet().iterator(); while (itr.hasNext()) { - removeKeyBinding(itr.next().toString()); + removeKeyBinding((KeyStroke)itr.next()); } }//}}} + //{{{ handleKey() + /** + * Handles a key event. If the event matches any key bindings the + * associated action is invoked. + */ + public static void handleKey(KeyEvent event) { + KeyStroke key = KeyStroke.getKeyStrokeForEvent(event); + Action action = (Action)m_keyBindingMap.get(key); + }//}}} + //{{{ Wrapper class /** * The Wrapper class wraps LocalizedActions so they can be invoked @@ -283,12 +304,25 @@ private static void invokeAction(LocalizedAction action, ActionEvent evt) { if (action != null) { Log.log(Log.MESSAGE, ActionManager.class, "Invoking action "+action.getName()); - action.invoke((TabbedView)MiscUtilities.getComponentParent((java.awt.Component)evt.getSource(), TabbedView.class), evt); + action.invoke(GUIUtilities.getView((java.awt.Component)evt.getSource()), evt); } }//}}} //{{{ ActionManager constructor private ActionManager() {}//}}} + //{{{ removeKeyBinding() + /** + * Removes a key binding. + * @param keyBinding The key binding + */ + public static void removeKeyBinding(KeyStroke key) { + Action action = (Action)m_keyBindingMap.get(key); + if (action != null) { + action.putValue(Action.ACCELERATOR_KEY, null); + m_keyBindingMap.remove(key); + } + }//}}} + //}}} } Modified: trunk/jsxe/src/net/sourceforge/jsxe/ActionSet.java =================================================================== --- trunk/jsxe/src/net/sourceforge/jsxe/ActionSet.java 2006-06-25 19:12:04 UTC (rev 982) +++ trunk/jsxe/src/net/sourceforge/jsxe/ActionSet.java 2006-06-27 19:59:04 UTC (rev 983) @@ -116,7 +116,22 @@ public int getActionCount() { return actions.size(); }//}}} - + + //{{{ getActionNames() method + /** + * Returns an array of all action names in this action set. + * @since jsXe 0.5 pre1 + */ + public String[] getActionNames() { + String[] retVal = new String[actions.size()]; + Enumeration e = actions.keys(); + int i = 0; + while(e.hasMoreElements()) { + retVal[i++] = (String)e.nextElement(); + } + return retVal; + } //}}} + //{{{ getActions() /** * Returns an array of all actions in this action set. Modified: trunk/jsxe/src/net/sourceforge/jsxe/OperatingSystem.java =================================================================== --- trunk/jsxe/src/net/sourceforge/jsxe/OperatingSystem.java 2006-06-25 19:12:04 UTC (rev 982) +++ trunk/jsxe/src/net/sourceforge/jsxe/OperatingSystem.java 2006-06-27 19:59:04 UTC (rev 983) @@ -25,10 +25,15 @@ package net.sourceforge.jsxe; +import java.awt.GraphicsConfiguration; +import java.awt.GraphicsDevice; +import java.awt.GraphicsEnvironment; import java.awt.Rectangle; import java.awt.Toolkit; import javax.swing.UIManager; import java.io.File; +import java.util.Vector; +import java.util.Enumeration; /** * Operating system detection routines. @@ -73,6 +78,84 @@ return new Rectangle(x,y,w,h); }//}}} + //{{{ getScreenBounds() method + /** + * Returns the bounds of the (virtual) screen that the window should be in + * @param window The bounds of the window to get the screen for + * @since jsXe 0.5 pre1 + */ + public static final Rectangle getScreenBounds(Rectangle window) { + GraphicsDevice[] gd = GraphicsEnvironment.getLocalGraphicsEnvironment().getScreenDevices(); + Vector intersects = new Vector(); + + // Get available screens + // O(n^3), this is nasty, but since we aren't dealling with + // many items it should be fine + for (int i=0; i < gd.length; i++) { + GraphicsConfiguration gc = gd[i].getDefaultConfiguration(); + // Don't add duplicates + if (window.intersects(gc.getBounds())) { + for (Enumeration e = intersects.elements(); e.hasMoreElements();) { + GraphicsConfiguration gcc = (GraphicsConfiguration)e.nextElement(); + if (gcc.getBounds().equals(gc.getBounds())) { + break; + } + } + intersects.add(gc); + } + } + + GraphicsConfiguration choice = null; + if (intersects.size() > 0) { + // Pick screen with largest intersection + for (Enumeration e = intersects.elements(); e.hasMoreElements();) { + GraphicsConfiguration gcc = (GraphicsConfiguration)e.nextElement(); + if (choice == null) { + choice = gcc; + } else { + Rectangle int1 = choice.getBounds().intersection(window); + Rectangle int2 = gcc.getBounds().intersection(window); + int area1 = int1.width * int1.height; + int area2 = int2.width * int2.height; + if (area2 > area1) { + choice = gcc; + } + } + } + } else { + choice = GraphicsEnvironment.getLocalGraphicsEnvironment().getDefaultScreenDevice().getDefaultConfiguration(); + } + + // Make adjustments for some OS's + int screenX = (int)choice.getBounds().x; + int screenY = (int)choice.getBounds().y; + int screenW = (int)choice.getBounds().width; + int screenH = (int)choice.getBounds().height; + int x, y, w, h; + + if (isMacOS()) { + x = screenX; + y = screenY + 22; + w = screenW; + h = screenH - y - 4;//shadow size + } else { + if (isWindows()) { + x = screenX - 4; + y = screenY - 4; + w = screenW - 2*x; + h = screenH - 2*y; + } else { + x = screenX; + y = screenY; + w = screenW; + h = screenH; + } + } + + // Yay, we're finally there + return new Rectangle(x,y,w,h); + } //}}} + //{{{ isDOSDerived() method /** * Returns if we're running Windows 95/98/ME/NT/2000/XP, or OS/2. Added: trunk/jsxe/src/net/sourceforge/jsxe/gui/GUIUtilities.java =================================================================== --- trunk/jsxe/src/net/sourceforge/jsxe/gui/GUIUtilities.java (rev 0) +++ trunk/jsxe/src/net/sourceforge/jsxe/gui/GUIUtilities.java 2006-06-27 19:59:04 UTC (rev 983) @@ -0,0 +1,1324 @@ +/* +GUIUtilities.java +:tabSize=4:indentSize=4:noTabs=true: +:folding=explicit:collapseFolds=1: + +Copyright (C) 1999, 2004 Slava Pestov +Portions 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 net.sourceforge.jsxe.gui; + +//{{{ Imports + +//{{{ jsXe classes +import net.sourceforge.jsxe.jsXe; +import net.sourceforge.jsxe.OperatingSystem; +import net.sourceforge.jsxe.util.Log; +import net.sourceforge.jsxe.util.MiscUtilities; +//}}} + +//{{{ Swing classes +import javax.swing.*; +//}}} + +//{{{ AWT classes +import java.awt.*; +import java.awt.event.*; +//}}} + +//{{{ Java classes +import java.net.*; +import java.util.*; +//}}} + +//}}} + +/** + * Various GUI functions.<p> + * + * The most frequently used members of this class are: + * + * <ul> + * <li>{@link #loadIcon(String)}</li> + * <li>{@link #confirm(Component,String,Object[],int,int)}</li> + * <li>{@link #error(Component,String,Object[])}</li> + * <li>{@link #message(Component,String,Object[])}</li> + * <li>{@link #showPopupMenu(JPopupMenu,Component,int,int)}</li> + * <li>{@link #showVFSFileDialog(View,String,int,boolean)}</li> + * <li>{@link #loadGeometry(Window,String)}</li> + * <li>{@link #saveGeometry(Window,String)}</li> + * </ul> + * + * @author Slava Pestov + * @author Ian Lewis (<a href="mailto:Ian...@me...">Ian...@me...</a>) + * @version $Id$ + */ +public class GUIUtilities { + + //{{{ Icon methods + + //{{{ setIconPath() method + /** + * Sets the path where jsXe looks for icons. + */ + public static void setIconPath(String iconPath) { + GUIUtilities.iconPath = iconPath; + if (icons != null) { + icons.clear(); + } + } //}}} + + //{{{ loadIcon() method + /** + * Loads an icon. + * @param iconName The icon name + */ + public static Icon loadIcon(String iconName) { + if (icons == null) { + icons = new Hashtable(); + } + // check if there is a cached version first + ImageIcon icon = (ImageIcon)icons.get(iconName); + if (icon != null) { + return icon; + } + + // get the icon + if (MiscUtilities.isURL(iconName)) { + icon = new ImageIcon(iconName.substring(5)); + } else { + try { + URL url = GUIUtilities.class.getResource(iconPath + iconName); + icon = new ImageIcon(url); + } catch(Exception e) { + try { + URL url = GUIUtilities.class.getResource(defaultIconPath + iconName); + icon = new ImageIcon(url); + } catch(Exception ex) { + Log.log(Log.ERROR,GUIUtilities.class, "Icon not found: " + iconName); + Log.log(Log.ERROR,GUIUtilities.class,ex); + return null; + } + } + } + + icons.put(iconName,icon); + return icon; + } //}}} + + //}}} + + //{{{ Menus, tool bars + + // //{{{ loadMenuBar() method + // /** + // * Creates a menubar. Plugins should not need to call this method. + // * @param name The menu bar name + // */ + // public static JMenuBar loadMenuBar(String name) { + // return loadMenuBar(jsXe.getActionContext(),name); + // } //}}} + + // //{{{ loadMenuBar() method + // /** + // * Creates a menubar. Plugins should not need to call this method. + // * @param context An action context + // * @param name The menu bar name + // */ + // public static JMenuBar loadMenuBar(ActionContext context, String name) { + // String menus = jEdit.getProperty(name); + // StringTokenizer st = new StringTokenizer(menus); + + // JMenuBar mbar = new JMenuBar(); + + // while(st.hasMoreTokens()) + // { + // mbar.add(loadMenu(context,st.nextToken())); + // } + + // return mbar; + // } //}}} + + // //{{{ loadMenu() method + // /** + // * Creates a menu. The menu label is set from the + // * <code><i>name</i>.label</code> property. The menu contents is taken + // * from the <code><i>name</i></code> property, which is a whitespace + // * separated list of action names. An action name of <code>-</code> + // * inserts a separator in the menu. + // * @param name The menu name + // * @see #loadMenuItem(String) + // */ + // public static JMenu loadMenu(String name) + // { + // return loadMenu(jEdit.getActionContext(),name); + // } //}}} + + // //{{{ loadMenu() method + // /** + // * Creates a menu. The menu label is set from the + // * <code><i>name</i>.label</code> property. The menu contents is taken + // * from the <code><i>name</i></code> property, which is a whitespace + // * separated list of action names. An action name of <code>-</code> + // * inserts a separator in the menu. + // * @param context An action context; either + // * <code>jEdit.getActionContext()</code> or + // * <code>VFSBrowser.getActionContext()</code>. + // * @param name The menu name + // * @see #loadMenuItem(String) + // */ + // public static JMenu loadMenu(ActionContext context, String name) + // { + // return new EnhancedMenu(name, + // jEdit.getProperty(name.concat(".label")), + // context); + // } //}}} + + // //{{{ loadPopupMenu() method + // /** + // * Creates a popup menu. + + // * @param name The menu name + // */ + // public static JPopupMenu loadPopupMenu(String name) + // { + // return loadPopupMenu(jEdit.getActionContext(),name); + // } //}}} + + // //{{{ loadPopupMenu() method + // /** + // * Creates a popup menu. + + // * @param context An action context; either + // * <code>jEdit.getActionContext()</code> or + // * <code>VFSBrowser.getActionContext()</code>. + // * @param name The menu name + // */ + // public static JPopupMenu loadPopupMenu(ActionContext context, String name) + // { + // JPopupMenu menu = new JPopupMenu(); + + // String menuItems = jEdit.getProperty(name); + // if(menuItems != null) + // { + // StringTokenizer st = new StringTokenizer(menuItems); + // while(st.hasMoreTokens()) + // { + // String menuItemName = st.nextToken(); + // if(menuItemName.equals("-")) + // menu.addSeparator(); + // else + // menu.add(loadMenuItem(context,menuItemName,false)); + // } + // } + + // return menu; + // } //}}} + + // //{{{ loadMenuItem() method + // /** + // * Creates a menu item. The menu item is bound to the action named by + // * <code>name</code> with label taken from the return value of the + // * {@link EditAction#getLabel()} method. + // * + // * @param name The menu item name + // * @see #loadMenu(String) + // */ + // public static JMenuItem loadMenuItem(String name) + // { + // return loadMenuItem(jEdit.getActionContext(),name,true); + // } //}}} + + // //{{{ loadMenuItem() method + // /** + // * Creates a menu item. + // * @param name The menu item name + // * @param setMnemonic True if the menu item should have a mnemonic + // */ + // public static JMenuItem loadMenuItem(String name, boolean setMnemonic) + // { + // return loadMenuItem(jEdit.getActionContext(),name,setMnemonic); + // } //}}} + + // //{{{ loadMenuItem() method + // /** + // * Creates a menu item. + // * @param context An action context; either + // * <code>jEdit.getActionContext()</code> or + // * <code>VFSBrowser.getActionContext()</code>. + // * @param name The menu item name + // * @param setMnemonic True if the menu item should have a mnemonic + // */ + // public static JMenuItem loadMenuItem(ActionContext context, String name, + // boolean setMnemonic) + // { + // if(name.startsWith("%")) + // return loadMenu(context,name.substring(1)); + + // String label = jEdit.getProperty(name + ".label"); + // if(label == null) + // label = name; + + // char mnemonic; + // int index = label.indexOf('$'); + // if(index != -1 && label.length() - index > 1) + // { + // mnemonic = Character.toLowerCase(label.charAt(index + 1)); + // label = label.substring(0,index).concat(label.substring(++index)); + // } + // else + // mnemonic = '\0'; + + // JMenuItem mi; + // if(jEdit.getBooleanProperty(name + ".toggle")) + // mi = new EnhancedCheckBoxMenuItem(label,name,context); + // else + // mi = new EnhancedMenuItem(label,name,context); + + // if(!OperatingSystem.isMacOS() && setMnemonic && mnemonic != '\0') + // mi.setMnemonic(mnemonic); + + // return mi; + // } //}}} + + // //{{{ loadToolBar() method + // /** + // * Creates a toolbar. + // * @param name The toolbar name + // */ + // public static Box loadToolBar(String name) + // { + // return loadToolBar(jEdit.getActionContext(),name); + // } //}}} + + // //{{{ loadToolBar() method + // /** + // * Creates a toolbar. + // * @param context An action context; either + // * <code>jEdit.getActionContext()</code> or + // * <code>VFSBrowser.getActionContext()</code>. + // * @param name The toolbar name + // */ + // public static Box loadToolBar(ActionContext context, String name) + // { + // Box toolBar = new Box(BoxLayout.X_AXIS); + + // String buttons = jEdit.getProperty(name); + // if(buttons != null) + // { + // StringTokenizer st = new StringTokenizer(buttons); + // while(st.hasMoreTokens()) + // { + // String button = st.nextToken(); + // if(button.equals("-")) + // toolBar.add(Box.createHorizontalStrut(12)); + // else + // { + // JButton b = loadToolButton(context,button); + // if(b != null) + // toolBar.add(b); + // } + // } + // } + + // toolBar.add(Box.createGlue()); + + // return toolBar; + // } //}}} + + // //{{{ loadToolButton() method + // /** + // * Loads a tool bar button. The tooltip is constructed from + // * the <code><i>name</i>.label</code> and + // * <code><i>name</i>.shortcut</code> properties and the icon is loaded + // * from the resource named '/org/gjt/sp/jedit/icons/' suffixed + // * with the value of the <code><i>name</i>.icon</code> property. + // * @param name The name of the button + // */ + // public static EnhancedButton loadToolButton(String name) + // { + // return loadToolButton(jEdit.getActionContext(),name); + // } //}}} + + // //{{{ loadToolButton() method + // /** + // * Loads a tool bar button. The tooltip is constructed from + // * the <code><i>name</i>.label</code> and + // * <code><i>name</i>.shortcut</code> properties and the icon is loaded + // * from the resource named '/org/gjt/sp/jedit/icons/' suffixed + // * with the value of the <code><i>name</i>.icon</code> property. + // * @param context An action context; either + // * <code>jEdit.getActionContext()</code> or + // * <code>VFSBrowser.getActionContext()</code>. + // * @param name The name of the button + // */ + // public static EnhancedButton loadToolButton(ActionContext context, + // String name) + // { + // String label = jEdit.getProperty(name + ".label"); + + // if(label == null) + // label = name; + + // Icon icon; + // String iconName = jEdit.getProperty(name + ".icon"); + // if(iconName == null) + // icon = loadIcon("BrokenImage.png"); + // else + // { + // icon = loadIcon(iconName); + // if(icon == null) + // icon = loadIcon("BrokenImage.png"); + // } + + // String toolTip = prettifyMenuLabel(label); + // String shortcut1 = jEdit.getProperty(name + ".shortcut"); + // String shortcut2 = jEdit.getProperty(name + ".shortcut2"); + // if(shortcut1 != null || shortcut2 != null) + // { + // toolTip = toolTip + " (" + // + (shortcut1 != null + // ? shortcut1 : "") + // + ((shortcut1 != null && shortcut2 != null) + // ? " or " : "") + // + (shortcut2 != null + // ? shortcut2 + // : "") + ")"; + // } + + // return new EnhancedButton(icon,toolTip,name,context); + // } //}}} + + // //{{{ prettifyMenuLabel() method + // /** + // * `Prettifies' a menu item label by removing the `$' sign. This + // * can be used to process the contents of an <i>action</i>.label + // * property. + // */ + // public static String prettifyMenuLabel(String label) + // { + // int index = label.indexOf('$'); + // if(index != -1) + // { + // label = label.substring(0,index) + // .concat(label.substring(index + 1)); + // } + // return label; + // } //}}} + + //}}} + + //{{{ Canned dialog boxes + + //{{{ message() method + /** + * Displays a dialog box. + * The title of the dialog is fetched from + * the <code><i>name</i>.title</code> property. The message is fetched + * from the <code><i>name</i>.message</code> property. The message + * is formatted by the property manager with <code>args</code> as + * positional parameters. + * @param comp The component to display the dialog for + * @param name The name of the dialog + * @param args Positional parameters to be substituted into the + * message text + */ + public static void message(Component comp, String name, Object[] args) { + hideSplashScreen(); + + JOptionPane.showMessageDialog(comp, + Messages.getMessage(name.concat(".message"),args), + Messages.getMessage(name.concat(".title"),args), + JOptionPane.INFORMATION_MESSAGE); + } //}}} + + //{{{ error() method + /** + * Displays an error dialog box. + * The title of the dialog is fetched from + * the <code><i>name</i>.title</code> property. The message is fetched + * from the <code><i>name</i>.message</code> property. The message + * is formatted by the property manager with <code>args</code> as + * positional parameters. + * @param comp The component to display the dialog for + * @param name The name of the dialog + * @param args Positional parameters to be substituted into the + * message text + */ + public static void error(Component comp, String name, Object[] args) { + hideSplashScreen(); + + JOptionPane.showMessageDialog(comp, + Messages.getMessage(name.concat(".message"),args), + Messages.getMessage(name.concat(".title"),args), + JOptionPane.ERROR_MESSAGE); + } //}}} + + //{{{ input() method + /** + * Displays an input dialog box and returns any text the user entered. + * The title of the dialog is fetched from + * the <code><i>name</i>.title</code> property. The message is fetched + * from the <code><i>name</i>.message</code> property. + * @param comp The component to display the dialog for + * @param name The name of the dialog + * @param def The text to display by default in the input field + */ + public static String input(Component comp, String name, Object def) + { + return input(comp,name,null,def); + } //}}} + + //{{{ inputProperty() method + /** + * Displays an input dialog box and returns any text the user entered. + * The title of the dialog is fetched from + * the <code><i>name</i>.title</code> property. The message is fetched + * from the <code><i>name</i>.message</code> property. + * @param comp The component to display the dialog for + * @param name The name of the dialog + * @param def The property whose text to display in the input field + */ + public static String inputProperty(Component comp, String name, + String def) + { + return inputProperty(comp,name,null,def); + } //}}} + + //{{{ input() method + /** + * Displays an input dialog box and returns any text the user entered. + * The title of the dialog is fetched from + * the <code><i>name</i>.title</code> property. The message is fetched + * from the <code><i>name</i>.message</code> property. + * @param comp The component to display the dialog for + * @param name The name of the dialog + * @param def The text to display by default in the input field + * @param args Positional parameters to be substituted into the + * message text + */ + public static String input(Component comp, String name, + Object[] args, Object def) + { + hideSplashScreen(); + + String retVal = (String)JOptionPane.showInputDialog(comp, + Messages.getMessage(name.concat(".message"),args), + Messages.getMessage(name.concat(".title")), + JOptionPane.QUESTION_MESSAGE,null,null,def); + return retVal; + } //}}} + + //{{{ inputProperty() method + /** + * Displays an input dialog box and returns any text the user entered. + * The title of the dialog is fetched from + * the <code><i>name</i>.title</code> property. The message is fetched + * from the <code><i>name</i>.message</code> property. + * @param comp The component to display the dialog for + * @param name The name of the dialog + * @param args Positional parameters to be substituted into the + * message text + * @param def The property whose text to display in the input field + */ + public static String inputProperty(Component comp, String name, + Object[] args, String def) + { + hideSplashScreen(); + + String retVal = (String)JOptionPane.showInputDialog(comp, + Messages.getMessage(name.concat(".message"),args), + Messages.getMessage(name.concat(".title")), + JOptionPane.QUESTION_MESSAGE, + null,null,jsXe.getProperty(def)); + if (retVal != null) { + jsXe.setProperty(def,retVal); + } + return retVal; + } //}}} + + //{{{ confirm() method + /** + * Displays a confirm dialog box and returns the button pushed by the + * user. The title of the dialog is fetched from the + * <code><i>name</i>.title</code> property. The message is fetched + * from the <code><i>name</i>.message</code> property. + * @param com... [truncated message content] |
|
From: <ian...@us...> - 2006-07-06 21:27:00
|
Revision: 989 Author: ian_lewis Date: 2006-07-06 14:26:48 -0700 (Thu, 06 Jul 2006) ViewCVS: http://svn.sourceforge.net/jsxe/?rev=989&view=rev Log Message: ----------- rewrote Messages Modified Paths: -------------- trunk/jsxe/Changelog trunk/jsxe/src/net/sourceforge/jsxe/JARClassLoader.java trunk/jsxe/src/net/sourceforge/jsxe/gui/Messages.java trunk/jsxe/src/net/sourceforge/jsxe/jsXe.java trunk/jsxe/src/net/sourceforge/jsxe/util/MiscUtilities.java Modified: trunk/jsxe/Changelog =================================================================== --- trunk/jsxe/Changelog 2006-07-06 16:51:38 UTC (rev 988) +++ trunk/jsxe/Changelog 2006-07-06 21:26:48 UTC (rev 989) @@ -1,3 +1,10 @@ +07/06/2006 Ian Lewis <Ian...@me...> + + * Rewrote the Messages class. Now it loads messages on demand and only + loads the messages that it needs but allows the Locale to be changed at + any time. Though this implementation is inefficient as it checks for + messages files in plugins every time a message is requested. + 06/27/2006 Ian Lewis <Ian...@me...> * Added the GUIUtilities class for handling utility functions in jsXe. Modified: trunk/jsxe/src/net/sourceforge/jsxe/JARClassLoader.java =================================================================== --- trunk/jsxe/src/net/sourceforge/jsxe/JARClassLoader.java 2006-07-06 16:51:38 UTC (rev 988) +++ trunk/jsxe/src/net/sourceforge/jsxe/JARClassLoader.java 2006-07-06 21:26:48 UTC (rev 989) @@ -191,7 +191,31 @@ return null; }//}}} - + + //{{{ getPluginResources() + /** + * Finds all resources matching the name in the jar files specified in the + * search path. The search path is specified by the + * {@link addJarFile(String)}, {@link addJarFile(File)}, and + * {@link addDirectory(String)} methods. + * @param name the name of the resources to find + */ + public Enumeration getPluginResources(String name) throws IOException { + return findResources(name); + }//}}} + + //{{{ getPluginResource() + /** + * Finds the first resource matching the name in the jar files specified + * in the search path. The search path is specified by the + * {@link addJarFile(String)}, {@link addJarFile(File)}, and + * {@link addDirectory(String)} methods. + * @param name the name of the resources to find + */ + public URL getPluginResource(String name) { + return findResource(name); + }//}}} + //}}} //{{{ addJarFile() @@ -703,22 +727,22 @@ checkDependencies(jarfile); //load the plugin's localized messages - Log.log(Log.NOTICE, this, "Loading localized messages for plugin: "+pluginName); - Properties pluginMessages = new Properties(); - try { - InputStream stream = jarfile.getInputStream(jarfile.getEntry("messages/messages.en")); - pluginMessages.load(stream); - Messages.loadPluginMessages(pluginMessages); - } catch (IOException e) { - Log.log(Log.WARNING, this, "Plugin "+pluginName+" does not have default messages.en"); - } - try { - InputStream stream = jarfile.getInputStream(jarfile.getEntry("messages/messages."+Messages.getLanguage())); - pluginMessages.load(stream); - Messages.loadPluginMessages(pluginMessages); - } catch (IOException e) { - Log.log(Log.WARNING, this, "Plugin "+pluginName+" does not have localized messages."+Messages.getLanguage()); - } + // Log.log(Log.NOTICE, this, "Loading localized messages for plugin: "+pluginName); + // Properties pluginMessages = new Properties(); + // try { + // InputStream stream = jarfile.getInputStream(jarfile.getEntry("messages/messages.en")); + // pluginMessages.load(stream); + // Messages.loadPluginMessages(pluginMessages); + // } catch (IOException e) { + // Log.log(Log.WARNING, this, "Plugin "+pluginName+" does not have default messages.en"); + // } + // try { + // InputStream stream = jarfile.getInputStream(jarfile.getEntry("messages/messages."+Messages.getLanguage())); + // pluginMessages.load(stream); + // Messages.loadPluginMessages(pluginMessages); + // } catch (IOException e) { + // Log.log(Log.WARNING, this, "Plugin "+pluginName+" does not have localized messages."+Messages.getLanguage()); + // } Class pluginClass = loadClass(mainPluginClass); Modified: trunk/jsxe/src/net/sourceforge/jsxe/gui/Messages.java =================================================================== --- trunk/jsxe/src/net/sourceforge/jsxe/gui/Messages.java 2006-07-06 16:51:38 UTC (rev 988) +++ trunk/jsxe/src/net/sourceforge/jsxe/gui/Messages.java 2006-07-06 21:26:48 UTC (rev 989) @@ -34,16 +34,16 @@ //{{{ Java base classes import java.io.*; -import java.util.Locale; -import java.util.Properties; -import java.util.Enumeration; -import java.util.Iterator; +import java.util.*; import java.text.MessageFormat; +import java.net.URL; //}}} //{{{ jsXe classes import net.sourceforge.jsxe.jsXe; +import net.sourceforge.jsxe.JARClassLoader; import net.sourceforge.jsxe.util.Log; +import net.sourceforge.jsxe.util.MiscUtilities; //}}} //}}} @@ -55,10 +55,17 @@ * {@link #setLanguage(String)} method. * * Messages are automatically loaded from the properties files located in the - * 'messages' directory in the jsXe install. These files are named - * <code>message.<i>language</i></code>. Where language is the ISO-639 language - * code. The default being english. + * 'messages' directory in the jsXe install directory. The messages files are + * names with the format messages.<code>language</code>.<code>country</code>.<code>variant</code>. + * The Messages class searches these files in the following order. * + * <ul> + * <li>messages.<code>language</code>.<code>country</code>.<code>variant</code></li> + * <li>messages.<code>language</code>.<code>country</code></li> + * <li>messages.<code>language</code></li> + * <li>messages</li> + * </ul> + * * @author Trish Hartnett (<a href="mailto:tri...@me...">tri...@me...</a>) * @author Ian Lewis (<a href="mailto:Ian...@me...">Ian...@me...</a>) * @version $Id$ @@ -68,28 +75,154 @@ public class Messages { //{{{ Private static members - private static Properties m_propertiesObject = new Properties(); - private static Properties m_pluginMessages = new Properties(); - private static Properties m_defaultProperties = new Properties(); - private static String m_language; - private static String m_directory = "."; //default to current directory - //}}} + /** + * A Locale to Properties object map which is used when searching + * for a message resource. + */ + private static HashMap m_messagesMap = new HashMap(); + /** + * This is a list of URLs messages files for plugins which have been loaded. + */ + private static ArrayList m_resources = new ArrayList(); + /** + * The default properties file + */ + private static Properties m_default; + private static Locale m_locale = Locale.getDefault(); - //{{{ getLanguage() + //{{{ getMessagesFileName() + private static String getMessagesFileName(Locale locale) { + StringBuffer messagesFile = new StringBuffer("messages"); + + if (locale != null) { + String language = locale.getLanguage(); + if (language != null && !language.equals("")) { + messagesFile.append(".").append(language); + + String country = locale.getCountry(); + if (country != null && !country.equals("")) { + messagesFile.append(".").append(country); + + String variant = locale.getVariant(); + if (variant != null && !variant.equals("")) { + messagesFile.append(".").append(variant); + } + } + } + } + + return messagesFile.toString(); + }//}}} + + //{{{ loadMessages() /** - * @return Returns the ISO-639 language code. + * @param locale the locale to use when searching for the messages file. + * The language, country, and variant must be exact. Null + * loads the default messages file. */ - public static String getLanguage() { - return m_language; + private static Properties loadMessages(Locale locale) { + Properties props = null; + try { + + if (locale != null) { + props = (Properties)m_messagesMap.get(locale); + } else { + props = m_default; + } + + if (props == null) { + //{{{ Load the properties file + + String messagesFile = getMessagesFileName(locale); + + //create input stream from messages file + FileInputStream in = new FileInputStream(jsXe.getInstallDirectory()+ + System.getProperty("file.separator")+ + "messages"+ + System.getProperty("file.separator")+ + messagesFile.toString()); + Log.log(Log.NOTICE, Messages.class, "Loading messages file: "+messagesFile); + props = new Properties(); + props.load(in); + if (locale != null) { + m_messagesMap.put(locale, props); + } else { + m_default = props; + } + //}}} + } + } catch (FileNotFoundException e) { + // just fall through + } catch(IOException e) { + Log.log(Log.ERROR, Messages.class, e); + } + + //{{{ Check for plugin resources + // Log.log(Log.DEBUG, Messages.class, "loading plugin messages"); + try { + JARClassLoader loader = jsXe.getPluginLoader(); + if (loader != null) { + String messagesFile = getMessagesFileName(locale); + //TODO: inefficient + Enumeration pluginMessages = loader.getPluginResources("messages/"+messagesFile); + // Log.log(Log.DEBUG, Messages.class, "looking for: "+"messages/"+messagesFile); + while (pluginMessages.hasMoreElements()) { + URL resource = (URL)pluginMessages.nextElement(); + // Log.log(Log.DEBUG, Messages.class, resource.toString()); + if (!m_resources.contains(resource)) { + Properties resourceProps = new Properties(); + Log.log(Log.NOTICE, Messages.class, "Loading plugin messages file: "+resource.toString()); + resourceProps.load(resource.openStream()); + props = MiscUtilities.mergeProperties(props, resourceProps); + m_resources.add(resource); + if (locale != null) { + m_messagesMap.put(locale, props); + } else { + m_default = props; + } + } + } + } + } catch(IOException e) { + Log.log(Log.ERROR, Messages.class, e); + }//}}} + + return props; }//}}} - //{{{ setLanguage() + //{{{ getMessages() /** - * @param newLanguage The ISO-639 language code + * Searches the available resources for a resource where it can draw + * the messages that are needed for the current locale. */ - public static void setLanguage(String newLanguage) { - initLocale(newLanguage, m_directory); + private static Properties getMessages(Locale locale) { + Properties messages = loadMessages(locale); + if (messages == null) { + messages = loadMessages(new Locale(locale.getLanguage(), locale.getCountry())); + if (messages == null) { + messages = loadMessages(new Locale(locale.getLanguage())); + if (messages == null) { + messages = loadMessages(null); + } + } + } + return messages; }//}}} + + //}}} + + //{{{ getLocale() + public Locale getLocale() { + return m_locale; + }//}}} + + //{{{ setLocale() + /** + * @param locale the new locale The ISO-639 language code + */ + public static void setLocale(Locale locale) { + m_locale = locale; + }//}}} //{{{ getMessage() /** @@ -103,15 +236,11 @@ * @return Returns the value of a property from the propertiesObject. */ public static synchronized String getMessage(String propertyName){ - if (m_language == null) { - //setLanguage("en"); - Locale newLocal = Locale.getDefault(); - String isoLanguage = newLocal.getLanguage(); - setLanguage(isoLanguage); - } + Properties messages = getMessages(m_locale); + //search in order, localized messages->default messages->plugin messages - String message = m_propertiesObject.getProperty(propertyName, m_defaultProperties.getProperty(propertyName, m_pluginMessages.getProperty(propertyName))); + String message = messages.getProperty(propertyName); if (message == null) { Log.log(Log.WARNING, Messages.class, "Unregistered message requested: "+propertyName); } @@ -155,78 +284,4 @@ } }//}}} - //{{{ initLocale() - /** - * Initializes localized messages for jsXe. - * @param language The language for the propertiesObject. - * @param directory The directory where the messages files are located. - */ - public static void initLocale(String language, String directory) { - String isoLanguage = language; - if (isoLanguage == null){ - //setLanguage("en"); - Locale newLocal = Locale.getDefault(); - isoLanguage = newLocal.getLanguage(); - } - - Log.log(Log.MESSAGE, Messages.class, "Loading messages for language: "+isoLanguage); - - File messagesFile = new File(directory+System.getProperty("file.separator")+"messages."+isoLanguage); - if (!messagesFile.exists()) { - Log.log(Log.WARNING, Messages.class, "Default messages file for current language not found"); - } else { - loadMessages(m_propertiesObject, messagesFile); - m_language = isoLanguage; - } - m_directory = directory; - - //load default english - messagesFile = new File(directory+System.getProperty("file.separator")+"messages.en"); - if (!messagesFile.exists()) { - Log.log(Log.ERROR, Messages.class, "Default messages file for English not found"); - } else { - if (m_language == null) { - m_language = "en"; - } - } - loadMessages(m_defaultProperties, messagesFile); - }//}}} - - //{{{ loadPluginMessages() - /** - * Loads the localized messages from installed plugins and merges them into - * the plugin messages. - * This method should only be called on jsXe startup. - */ - public static void loadPluginMessages(Properties pluginMessages) { - Enumeration names = pluginMessages.propertyNames(); - while (names.hasMoreElements()) { - String name = names.nextElement().toString(); - String message = pluginMessages.getProperty(name); - m_pluginMessages.setProperty(name, message); - } - }//}}} - - //{{{ Private Members - - //{{{ loadMessages() - /** - * - * @param propertiesObject The propertiesObject which will store the values from the messages file. - * @param messssagesFile The name of the messages file to be used. - */ - private static void loadMessages(Properties propertiesObject, File messagesFile) { - try { - //create input stream from messages file - FileInputStream in = new FileInputStream(messagesFile); - propertiesObject.load(in); - } catch (FileNotFoundException e) { - Log.log(Log.ERROR, Messages.class, e); - } catch(IOException e) { - Log.log(Log.ERROR, Messages.class, e); - } - }//}}} - - //}}} - } Modified: trunk/jsxe/src/net/sourceforge/jsxe/jsXe.java =================================================================== --- trunk/jsxe/src/net/sourceforge/jsxe/jsXe.java 2006-07-06 16:51:38 UTC (rev 988) +++ trunk/jsxe/src/net/sourceforge/jsxe/jsXe.java 2006-07-06 21:26:48 UTC (rev 989) @@ -123,7 +123,7 @@ if(!_pluginsDirectory.exists()) _pluginsDirectory.mkdirs(); - String jsXeHome = System.getProperty("jsxe.home"); + jsXeHome = System.getProperty("jsxe.home"); if (jsXeHome == null) { String classpath = System.getProperty("java.class.path"); int index = classpath.toLowerCase().indexOf("jsxe.jar"); @@ -143,10 +143,6 @@ //}}} - //{{{ start locale - Messages.initLocale(null, jsXeHome+fileSep+"messages"); - //}}} - //{{{ get and load the configuration files initDefaultProps(); //}}} @@ -458,6 +454,23 @@ return jsXeIcon; }//}}} + //{{{ getHomeDirectory() method + /** + * Returns the path to where jsXe is installed + */ + public static String getInstallDirectory() { + return jsXeHome; + } //}}} + + + //{{{ getHomeDirectory() method + /** + * Returns the path to the user's home directory. + */ + public static String getHomeDirectory() { + return m_homeDirectory; + } //}}} + //{{{ getSettingsDirectory() method /** * Returns the path of the directory where user-specific settings @@ -1336,6 +1349,7 @@ private static TabbedView m_activeView; private static String m_settingsDirectory; private static String m_homeDirectory; + private static String jsXeHome; private static OptionPane jsXeOptions; //}}} Modified: trunk/jsxe/src/net/sourceforge/jsxe/util/MiscUtilities.java =================================================================== --- trunk/jsxe/src/net/sourceforge/jsxe/util/MiscUtilities.java 2006-07-06 16:51:38 UTC (rev 988) +++ trunk/jsxe/src/net/sourceforge/jsxe/util/MiscUtilities.java 2006-07-06 21:26:48 UTC (rev 989) @@ -1307,6 +1307,44 @@ //}}} + //{{{ mergeProperties() + /** + * Merges two Properties sets together into a new Properties object + * giving precidence to the properties in the first argument. If either + * Properties object is null, the other Properties object is returned. + * If both are null then null is returned. + * + * @param props1 the first Properties object whose properties are given + * precidence. + * @param props2 the second Properties object whose properties are merged + * with that of the first. + */ + public static Properties mergeProperties(Properties props1, Properties props2) { + if (props1 == null) { + return props2; + } + + if (props2 == null) { + return props1; + } + + Properties props = new Properties(); + + Enumeration names = props2.propertyNames(); + while (names.hasMoreElements()) { + String name = names.nextElement().toString(); + props.setProperty(name, props2.getProperty(name)); + } + + names = props1.propertyNames(); + while (names.hasMoreElements()) { + String name = names.nextElement().toString(); + props.setProperty(name, props1.getProperty(name)); + } + + return props; + }//}}} + //{{{ isTrue() /** * Returns true if the value of the string is true 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:29
|
Revision: 994 Author: ian_lewis Date: 2006-07-06 20:46:17 -0700 (Thu, 06 Jul 2006) ViewCVS: http://svn.sourceforge.net/jsxe/?rev=994&view=rev Log Message: ----------- Added support for countries and language variants Modified Paths: -------------- trunk/jsxe/Changelog trunk/jsxe/src/net/sourceforge/jsxe/JARClassLoader.java trunk/jsxe/src/net/sourceforge/jsxe/gui/Messages.java trunk/jsxe/src/net/sourceforge/jsxe/jsXe.java trunk/jsxe/src/net/sourceforge/jsxe/util/Log.java Added Paths: ----------- trunk/jsxe/messages/messages Removed Paths: ------------- trunk/jsxe/messages/messages.en Modified: trunk/jsxe/Changelog =================================================================== --- trunk/jsxe/Changelog 2006-07-07 02:32:49 UTC (rev 993) +++ trunk/jsxe/Changelog 2006-07-07 03:46:17 UTC (rev 994) @@ -2,8 +2,7 @@ * Rewrote the Messages class. Now it loads messages on demand and only loads the messages that it needs but allows the Locale to be changed at - any time. Though this implementation is inefficient as it checks for - messages files in plugins every time a message is requested. + any time. It also now supports different countries and variants. 06/27/2006 Ian Lewis <Ian...@me...> Copied: trunk/jsxe/messages/messages (from rev 989, trunk/jsxe/messages/messages.en) =================================================================== --- trunk/jsxe/messages/messages (rev 0) +++ trunk/jsxe/messages/messages 2006-07-07 03:46:17 UTC (rev 994) @@ -0,0 +1,250 @@ +# JSXE English properties file +# $Id$ +#:mode=properties: +#:tabSize=4:indentSize=4:noTabs=true: +#:folding=explicit:collapseFolds=1: + +#{{{ common properties + +common.ok=OK +common.cancel=Cancel +common.open=Open +common.save=Save +common.save.as=Save As +common.close=Close +common.apply=Apply +common.more=More +common.insert=Insert +common.add=Add +common.remove=Remove +common.moveUp=Move Up +common.moveDown=Move Down +common.cut=Cut +common.copy=Copy +common.paste=Paste +common.find=Find... +common.findnext=Find Next + +#}}} + +#{{{ XML Terminology + +#{{{ XML Node Types +xml.element=Element +xml.processing.instruction=Processing Instruction +xml.cdata=CDATA Section +xml.text=Text +xml.entity.reference=Entity Reference +xml.declaration=Element Declaration +xml.notation=Notation +xml.entity=Entity Declaration +xml.comment=Comment +xml.attribute=Attribute +xml.doctype=Document Type +#}}} + +xml.attribute.value.short=Value +xml.attribute.value=Attribute Value +xml.document=XML Document +xml.namespace=Namespace +xml.namespace.prefix=Namespace Prefix +xml.namespace.prefix.short=Prefix +xml.namespace.decl=Namespace Declaration +xml.doctypedef=Document Type Definition +xml.doctype.name=Name +xml.doctype.public=Public Id +xml.doctype.system=System Id +xml.schema=XML Schema +#}}} + +#{{{ Global Options +Global.Options.Dialog.Title=Global Options +Global.Options.Title=General +Global.Options.Max.Recent.Files=Recent files to remember: +Global.Options.Max.Recent.Files.ToolTip=The maximum number of files that jsXe remembers in the recent files menu. +Global.Options.network-off=Always cache without asking +Global.Options.network-cache=Ask first, then cache remote files +Global.Options.network-always=Always download without asking +Global.Options.network=DTD and schema downloading: +Global.Options.Menu.Spill.Over=Number of items before menus spill over + + +Shortcuts.Options.Title=Shortcuts +#}}} + +#{{{ Document Options +Document.Options.Title=XML Document Options +Document.Options.Message=This dialog changes settings for the current\n document only. To change settings on an\n editor-wide basis, see the\n Tools->Global Options dialog box. +Document.Options.Line.Separator=Line Separator: +Document.Options.Line.Separator.ToolTip=The line separator. Usually you'll pick the line separator used by your operating system. +Document.Options.Encoding=Encoding: +Document.Options.Encoding.ToolTip=The encoding that jsXe uses to write the file. +Document.Options.Indent.Width=Indent width: +Document.Options.Indent.Width.ToolTip=The width used when formatting and displaying tab characters. +Document.Options.Format.XML=Format XML output +Document.Options.Format.XML.ToolTip=If this box is checked then XML will be formatted automatically. +Document.Options.Validate=Validate if DTD or Schema Available +Document.Options.Validate.ToolTip=If this box is checked jsXe will validate the XML document. +Document.Options.Soft.Tabs=Soft tabs (emulated with spaces) +Document.Options.Soft.Tabs.ToolTip=If this box is checked then tab characters are replaced by spaces. +#}}} + +#{{{ Plugin Manager +Plugin.Manager.Title=Plugin Manager +Plugin.Manager.Name.Column.Header=Name +Plugin.Manager.Version.Column.Header=Version +Plugin.Manager.Status.Column.Header=Status +Plugin.Manager.Loaded.Status=Loaded +Plugin.Manager.Not.Loaded.Status=Not Loaded +Plugin.Manager.Broken.Status=Error +#}}} + +#{{{ Menu Items + +File.Menu=File +Edit.Menu=Edit +View.Menu=View +Tools.Menu=Tools +Help.Menu=Help + +#{{{ File Menu Items +new-file.label=New +open-file.label=Open... +File.Recent=Recent Files +File.Recent.None=No Recent Files +save-file.label=Save +save-as.label=Save As... +reload-file.label=Reload +File.Recent=Recent Files +close-file.label=Close +close-all.label=Close All +exit.label=Exit +#}}} + +general-options.label=Global Options... +document-options.label=Document Options... +plugin-manager.label=Plugin Manager... +validation-errors.label=Validation Errors... +about-jsxe.label=About jsXe... +#}}} + +#{{{ Messages + +#{0} file name +DocumentBuffer.Reload.Message={0} unsaved!\n You will lose all unsaved changes if you reload!\n\nContinue? +DocumentBuffer.Reload.Message.Title=Document Modified +DocumentBuffer.SaveAs.Message=The file {0} already exists. Are you sure you want to overwrite it? +DocumentBuffer.SaveAs.Message.Title=File Exists +DocumentBuffer.Close.Message={0} unsaved! Save it now? +DocumentBuffer.Close.Message.Title=Unsaved Changes + +#{0} file name +DocumentBuffer.Saved.Message={0} Saved +DocumentBuffer.Closed.Message={0} Closed +DocumentBuffer.Loaded.Message={0} Loaded +DocumentBuffer.Reloaded.Message={0} Reloaded + +#{0} plugin name +DocumentView.Not.Found=No plugin a with name of {0} exists. + +#{{{ Plugin Load Messages + +# {0} plugin name +Plugin.Load.Already.Loaded=Plugin {0} already loaded. +Plugin.Load.Wrong.Main.Class=Main class is not a plugin class. +Plugin.Load.No.Plugin.Class=No plugin class defined. +Plugin.Load.No.Plugin.Name=No plugin name defined. +Plugin.Load.No.Plugin.HR.Name=No plugin human-readable name defined. +Plugin.Load.No.Plugin.Version=No plugin version defined. + +# {0} plugin name +# {1} requirement name +# {2} required version +# {3} found version +Plugin.Dependency.Message={0} requires {1} version {2} but only version {3} was found. +# {0} plugin name +# {1} requirement name +# {2} required version +Plugin.Dependency.Not.Found={0} requires {1} version {2} but {1} was not found. +# {0} plugin name +# {1} requirement name +Plugin.Dependency.Not.Found2={0} requires {1} but {1} was not found. +# {0} plugin name +# {1} invalid dependency +Plugin.Dependency.Invalid={0} has an invalid dependency: {1} +# {0} invalid version +Plugin.Dependency.Invalid.jsXe.Version=Invalid jsXe version number: {0} +# {0} plugin name +# {1} requirement name +Plugin.Dependency.No.Version=Cannot load plugin {0}, {1} has no version. +# {0} plugin name +# {1} requirement name +Plugin.Dependency.Failed.Load={0} requires plugin {1} but {1} did not load properly. + +#}}} + +#{{{ Error Messages +No.Xerces.Error={0} not found. jsXe requires Apache {0}. +No.Xerces.Error.Title={0} not found. +IO.Error.Title=I/O Error +#}}} + +#}}} + +#{{{ Dialogs + +#{{{ Download resource dialog +xml.download-resource.title=Getting resource from remote server + +#{0} URL +xml.download-resource.message=This XML file depends on a resource which is stored at the following\n\ + Internet address:\n\ + \n\ + {0}\n\ + \n\ + Do you want the XML plugin to download the resource and cache it\n\ + for future use?\n\ + \n\ + If you want resources to be downloaded every time without prompting,\n\ + disable the resource cache in jsXe's global options. +#}}} + +#{{{ Dirty Files Dialog +DirtyFilesDialog.Dialog.Title=Unsaved Changes +DirtyFilesDialog.Dialog.Message=The following files have unsaved changes: +DirtyFilesDialog.Button.SelectAll.Title=Select All +#DirtyFilesDialog.Button.SelectAll.ToolTip=Select All +DirtyFilesDialog.Button.SaveSelected.Title=Save Selected +#DirtyFilesDialog.Button.SaveSelected.ToolTip=Save Selected +DirtyFilesDialog.Button.DiscardSelected.Title=Discard Selected +#DirtyFilesDialog.Button.DiscardSelected.ToolTip=Discard Selected +#}}} + +#{{{ Activity Log Dialog +activity-log.label = Activity Log +ActivityLogDialog.Dialog.Title = Activity Log +ActivityLogDialog.Dialog.Message = Activity Log contents: +#}}} + +#{{{ About dialag +about.title=About jsXe +about.message=Released under the terms of the GNU General Public License\n\n\ + Active Contributors:\n\ + \ \ \ \ Ian Lewis <Ian...@me...>\n\ + \ \ \ \ Trish Hartnett <tri...@us...>\n\n\ + Translators:\n\ + \ \ \ \ German (de) - Bianca Schoen\n\ + \ \ \ \ Swedish (sv) - Patrik Johansson <pa...@it...>\n\n\ + Past Contributers:\n\ + \ \ \ \ Aaron Flatten <afl...@us...>\n\ + \ \ \ \ Bilel Remmache <rb...@us...>\n\ + \ \ \ \ SVM <svm...@us...>\n\n\ + Homepage: http://jsxe.sourceforge.net/ +#}}} + +#{{{ Validation Errors Dialog +ValidationErrors.title=Validation Errors +ValidationErrors.message=Validation Errors +#}}} + +#}}} \ No newline at end of file Deleted: trunk/jsxe/messages/messages.en =================================================================== --- trunk/jsxe/messages/messages.en 2006-07-07 02:32:49 UTC (rev 993) +++ trunk/jsxe/messages/messages.en 2006-07-07 03:46:17 UTC (rev 994) @@ -1,250 +0,0 @@ -# JSXE English properties file -# $Id$ -#:mode=properties: -#:tabSize=4:indentSize=4:noTabs=true: -#:folding=explicit:collapseFolds=1: - -#{{{ common properties - -common.ok=OK -common.cancel=Cancel -common.open=Open -common.save=Save -common.save.as=Save As -common.close=Close -common.apply=Apply -common.more=More -common.insert=Insert -common.add=Add -common.remove=Remove -common.moveUp=Move Up -common.moveDown=Move Down -common.cut=Cut -common.copy=Copy -common.paste=Paste -common.find=Find... -common.findnext=Find Next - -#}}} - -#{{{ XML Terminology - -#{{{ XML Node Types -xml.element=Element -xml.processing.instruction=Processing Instruction -xml.cdata=CDATA Section -xml.text=Text -xml.entity.reference=Entity Reference -xml.declaration=Element Declaration -xml.notation=Notation -xml.entity=Entity Declaration -xml.comment=Comment -xml.attribute=Attribute -xml.doctype=Document Type -#}}} - -xml.attribute.value.short=Value -xml.attribute.value=Attribute Value -xml.document=XML Document -xml.namespace=Namespace -xml.namespace.prefix=Namespace Prefix -xml.namespace.prefix.short=Prefix -xml.namespace.decl=Namespace Declaration -xml.doctypedef=Document Type Definition -xml.doctype.name=Name -xml.doctype.public=Public Id -xml.doctype.system=System Id -xml.schema=XML Schema -#}}} - -#{{{ Global Options -Global.Options.Dialog.Title=Global Options -Global.Options.Title=General -Global.Options.Max.Recent.Files=Recent files to remember: -Global.Options.Max.Recent.Files.ToolTip=The maximum number of files that jsXe remembers in the recent files menu. -Global.Options.network-off=Always cache without asking -Global.Options.network-cache=Ask first, then cache remote files -Global.Options.network-always=Always download without asking -Global.Options.network=DTD and schema downloading: -Global.Options.Menu.Spill.Over=Number of items before menus spill over - - -Shortcuts.Options.Title=Shortcuts -#}}} - -#{{{ Document Options -Document.Options.Title=XML Document Options -Document.Options.Message=This dialog changes settings for the current\n document only. To change settings on an\n editor-wide basis, see the\n Tools->Global Options dialog box. -Document.Options.Line.Separator=Line Separator: -Document.Options.Line.Separator.ToolTip=The line separator. Usually you'll pick the line separator used by your operating system. -Document.Options.Encoding=Encoding: -Document.Options.Encoding.ToolTip=The encoding that jsXe uses to write the file. -Document.Options.Indent.Width=Indent width: -Document.Options.Indent.Width.ToolTip=The width used when formatting and displaying tab characters. -Document.Options.Format.XML=Format XML output -Document.Options.Format.XML.ToolTip=If this box is checked then XML will be formatted automatically. -Document.Options.Validate=Validate if DTD or Schema Available -Document.Options.Validate.ToolTip=If this box is checked jsXe will validate the XML document. -Document.Options.Soft.Tabs=Soft tabs (emulated with spaces) -Document.Options.Soft.Tabs.ToolTip=If this box is checked then tab characters are replaced by spaces. -#}}} - -#{{{ Plugin Manager -Plugin.Manager.Title=Plugin Manager -Plugin.Manager.Name.Column.Header=Name -Plugin.Manager.Version.Column.Header=Version -Plugin.Manager.Status.Column.Header=Status -Plugin.Manager.Loaded.Status=Loaded -Plugin.Manager.Not.Loaded.Status=Not Loaded -Plugin.Manager.Broken.Status=Error -#}}} - -#{{{ Menu Items - -File.Menu=File -Edit.Menu=Edit -View.Menu=View -Tools.Menu=Tools -Help.Menu=Help - -#{{{ File Menu Items -new-file.label=New -open-file.label=Open... -File.Recent=Recent Files -File.Recent.None=No Recent Files -save-file.label=Save -save-as.label=Save As... -reload-file.label=Reload -File.Recent=Recent Files -close-file.label=Close -close-all.label=Close All -exit.label=Exit -#}}} - -general-options.label=Global Options... -document-options.label=Document Options... -plugin-manager.label=Plugin Manager... -validation-errors.label=Validation Errors... -about-jsxe.label=About jsXe... -#}}} - -#{{{ Messages - -#{0} file name -DocumentBuffer.Reload.Message={0} unsaved!\n You will lose all unsaved changes if you reload!\n\nContinue? -DocumentBuffer.Reload.Message.Title=Document Modified -DocumentBuffer.SaveAs.Message=The file {0} already exists. Are you sure you want to overwrite it? -DocumentBuffer.SaveAs.Message.Title=File Exists -DocumentBuffer.Close.Message={0} unsaved! Save it now? -DocumentBuffer.Close.Message.Title=Unsaved Changes - -#{0} file name -DocumentBuffer.Saved.Message={0} Saved -DocumentBuffer.Closed.Message={0} Closed -DocumentBuffer.Loaded.Message={0} Loaded -DocumentBuffer.Reloaded.Message={0} Reloaded - -#{0} plugin name -DocumentView.Not.Found=No plugin a with name of {0} exists. - -#{{{ Plugin Load Messages - -# {0} plugin name -Plugin.Load.Already.Loaded=Plugin {0} already loaded. -Plugin.Load.Wrong.Main.Class=Main class is not a plugin class. -Plugin.Load.No.Plugin.Class=No plugin class defined. -Plugin.Load.No.Plugin.Name=No plugin name defined. -Plugin.Load.No.Plugin.HR.Name=No plugin human-readable name defined. -Plugin.Load.No.Plugin.Version=No plugin version defined. - -# {0} plugin name -# {1} requirement name -# {2} required version -# {3} found version -Plugin.Dependency.Message={0} requires {1} version {2} but only version {3} was found. -# {0} plugin name -# {1} requirement name -# {2} required version -Plugin.Dependency.Not.Found={0} requires {1} version {2} but {1} was not found. -# {0} plugin name -# {1} requirement name -Plugin.Dependency.Not.Found2={0} requires {1} but {1} was not found. -# {0} plugin name -# {1} invalid dependency -Plugin.Dependency.Invalid={0} has an invalid dependency: {1} -# {0} invalid version -Plugin.Dependency.Invalid.jsXe.Version=Invalid jsXe version number: {0} -# {0} plugin name -# {1} requirement name -Plugin.Dependency.No.Version=Cannot load plugin {0}, {1} has no version. -# {0} plugin name -# {1} requirement name -Plugin.Dependency.Failed.Load={0} requires plugin {1} but {1} did not load properly. - -#}}} - -#{{{ Error Messages -No.Xerces.Error={0} not found. jsXe requires Apache {0}. -No.Xerces.Error.Title={0} not found. -IO.Error.Title=I/O Error -#}}} - -#}}} - -#{{{ Dialogs - -#{{{ Download resource dialog -xml.download-resource.title=Getting resource from remote server - -#{0} URL -xml.download-resource.message=This XML file depends on a resource which is stored at the following\n\ - Internet address:\n\ - \n\ - {0}\n\ - \n\ - Do you want the XML plugin to download the resource and cache it\n\ - for future use?\n\ - \n\ - If you want resources to be downloaded every time without prompting,\n\ - disable the resource cache in jsXe's global options. -#}}} - -#{{{ Dirty Files Dialog -DirtyFilesDialog.Dialog.Title=Unsaved Changes -DirtyFilesDialog.Dialog.Message=The following files have unsaved changes: -DirtyFilesDialog.Button.SelectAll.Title=Select All -#DirtyFilesDialog.Button.SelectAll.ToolTip=Select All -DirtyFilesDialog.Button.SaveSelected.Title=Save Selected -#DirtyFilesDialog.Button.SaveSelected.ToolTip=Save Selected -DirtyFilesDialog.Button.DiscardSelected.Title=Discard Selected -#DirtyFilesDialog.Button.DiscardSelected.ToolTip=Discard Selected -#}}} - -#{{{ Activity Log Dialog -activity-log.label = Activity Log -ActivityLogDialog.Dialog.Title = Activity Log -ActivityLogDialog.Dialog.Message = Activity Log contents: -#}}} - -#{{{ About dialag -about.title=About jsXe -about.message=Released under the terms of the GNU General Public License\n\n\ - Active Contributors:\n\ - \ \ \ \ Ian Lewis <Ian...@me...>\n\ - \ \ \ \ Trish Hartnett <tri...@us...>\n\n\ - Translators:\n\ - \ \ \ \ German (de) - Bianca Schoen\n\ - \ \ \ \ Swedish (sv) - Patrik Johansson <pa...@it...>\n\n\ - Past Contributers:\n\ - \ \ \ \ Aaron Flatten <afl...@us...>\n\ - \ \ \ \ Bilel Remmache <rb...@us...>\n\ - \ \ \ \ SVM <svm...@us...>\n\n\ - Homepage: http://jsxe.sourceforge.net/ -#}}} - -#{{{ Validation Errors Dialog -ValidationErrors.title=Validation Errors -ValidationErrors.message=Validation Errors -#}}} - -#}}} \ No newline at end of file Modified: trunk/jsxe/src/net/sourceforge/jsxe/JARClassLoader.java =================================================================== --- trunk/jsxe/src/net/sourceforge/jsxe/JARClassLoader.java 2006-07-07 02:32:49 UTC (rev 993) +++ trunk/jsxe/src/net/sourceforge/jsxe/JARClassLoader.java 2006-07-07 03:46:17 UTC (rev 994) @@ -192,6 +192,8 @@ return null; }//}}} + //}}} + //{{{ getPluginResources() /** * Finds all resources matching the name in the jar files specified in the @@ -216,8 +218,6 @@ return findResource(name); }//}}} - //}}} - //{{{ addJarFile() /** * Adds a jar file to the search path for the class loader and @@ -409,6 +409,9 @@ * @return an ArrayList of errors (either Strings or Exceptions). */ public ArrayList startPlugins() { + + Messages.initPluginMessages(); + Iterator jarItr = m_jarFiles.keySet().iterator(); ArrayList errors = new ArrayList(); Modified: trunk/jsxe/src/net/sourceforge/jsxe/gui/Messages.java =================================================================== --- trunk/jsxe/src/net/sourceforge/jsxe/gui/Messages.java 2006-07-07 02:32:49 UTC (rev 993) +++ trunk/jsxe/src/net/sourceforge/jsxe/gui/Messages.java 2006-07-07 03:46:17 UTC (rev 994) @@ -60,8 +60,8 @@ * The Messages class searches these files in the following order. * * <ul> - * <li>messages.<code>language</code>.<code>country</code>.<code>variant</code></li> - * <li>messages.<code>language</code>.<code>country</code></li> + * <li>messages.<code>language</code>_<code>country</code>_<code>variant</code></li> + * <li>messages.<code>language</code>_<code>country</code></li> * <li>messages.<code>language</code></li> * <li>messages</li> * </ul> @@ -76,152 +76,206 @@ //{{{ Private static members /** - * A Locale to Properties object map which is used when searching - * for a message resource. + * properties containing the messages for jsXe */ - private static HashMap m_messagesMap = new HashMap(); + private static Properties m_messages; /** - * This is a list of URLs messages files for plugins which have been loaded. + * plugin properties */ - private static ArrayList m_resources = new ArrayList(); - /** - * The default properties file - */ - private static Properties m_default; + private static Properties m_pluginMessages; + private static Locale m_locale = Locale.getDefault(); + private static boolean initialized = false; + private static boolean plugins_initialized = false; + //{{{ getMessagesFileName() private static String getMessagesFileName(Locale locale) { StringBuffer messagesFile = new StringBuffer("messages"); if (locale != null) { - String language = locale.getLanguage(); - if (language != null && !language.equals("")) { - messagesFile.append(".").append(language); + messagesFile.append(".").append(locale.toString()); + // String language = locale.getLanguage(); + // if (language != null && !language.equals("")) { + // messagesFile.append(".").append(language); - String country = locale.getCountry(); - if (country != null && !country.equals("")) { - messagesFile.append(".").append(country); + // String country = locale.getCountry(); + // if (country != null && !country.equals("")) { + // messagesFile.append(".").append(country); - String variant = locale.getVariant(); - if (variant != null && !variant.equals("")) { - messagesFile.append(".").append(variant); - } - } - } + // String variant = locale.getVariant(); + // if (variant != null && !variant.equals("")) { + // messagesFile.append(".").append(variant); + // } + // } + // } } return messagesFile.toString(); }//}}} //{{{ loadMessages() - /** - * @param locale the locale to use when searching for the messages file. - * The language, country, and variant must be exact. Null - * loads the default messages file. - */ - private static Properties loadMessages(Locale locale) { - Properties props = null; + private static void loadMessages(Locale locale) { + + String messagesFile = getMessagesFileName(locale); + try { - if (locale != null) { - props = (Properties)m_messagesMap.get(locale); - } else { - props = m_default; - } + //create input stream from messages file + FileInputStream in = new FileInputStream(jsXe.getInstallDirectory()+ + System.getProperty("file.separator")+ + "messages"+ + System.getProperty("file.separator")+ + messagesFile); - if (props == null) { - //{{{ Load the properties file - - String messagesFile = getMessagesFileName(locale); - - //create input stream from messages file - FileInputStream in = new FileInputStream(jsXe.getInstallDirectory()+ - System.getProperty("file.separator")+ - "messages"+ - System.getProperty("file.separator")+ - messagesFile.toString()); - Log.log(Log.NOTICE, Messages.class, "Loading messages file: "+messagesFile); - props = new Properties(); - props.load(in); - if (locale != null) { - m_messagesMap.put(locale, props); - } else { - m_default = props; - } - //}}} - } + Properties props = new Properties(); + + Log.log(Log.NOTICE, Messages.class, "Loading message file: "+messagesFile); + + props.load(in); + + m_messages = MiscUtilities.mergeProperties(m_messages, props); + } catch (FileNotFoundException e) { // just fall through } catch(IOException e) { Log.log(Log.ERROR, Messages.class, e); } + }//}}} + + //{{{ loadPluginMessages() + private static void loadPluginMessages(Locale locale) { - //{{{ Check for plugin resources - // Log.log(Log.DEBUG, Messages.class, "loading plugin messages"); + String messagesFile = getMessagesFileName(locale); + JARClassLoader loader = jsXe.getPluginLoader(); + + //create input stream from messages file try { - JARClassLoader loader = jsXe.getPluginLoader(); - if (loader != null) { - String messagesFile = getMessagesFileName(locale); - //TODO: inefficient - Enumeration pluginMessages = loader.getPluginResources("messages/"+messagesFile); - // Log.log(Log.DEBUG, Messages.class, "looking for: "+"messages/"+messagesFile); - while (pluginMessages.hasMoreElements()) { - URL resource = (URL)pluginMessages.nextElement(); - // Log.log(Log.DEBUG, Messages.class, resource.toString()); - if (!m_resources.contains(resource)) { - Properties resourceProps = new Properties(); - Log.log(Log.NOTICE, Messages.class, "Loading plugin messages file: "+resource.toString()); - resourceProps.load(resource.openStream()); - props = MiscUtilities.mergeProperties(props, resourceProps); - m_resources.add(resource); - if (locale != null) { - m_messagesMap.put(locale, props); - } else { - m_default = props; - } - } + Enumeration resources = loader.getPluginResources("messages/"+messagesFile); + + while (resources.hasMoreElements()) { + try { + Properties props = new Properties(); + URL resource = (URL)resources.nextElement(); + + Log.log(Log.NOTICE, Messages.class, "Loading plugin message file: "+resource.toString()); + + props.load(resource.openStream()); + + m_pluginMessages = MiscUtilities.mergeProperties(m_pluginMessages, props); + } catch (FileNotFoundException e) { + //fall through + } catch(IOException e) { + Log.log(Log.ERROR, Messages.class, e); } } } catch(IOException e) { Log.log(Log.ERROR, Messages.class, e); - }//}}} - - return props; + } + }//}}} - //{{{ getMessages() - /** - * Searches the available resources for a resource where it can draw - * the messages that are needed for the current locale. - */ - private static Properties getMessages(Locale locale) { - Properties messages = loadMessages(locale); - if (messages == null) { - messages = loadMessages(new Locale(locale.getLanguage(), locale.getCountry())); - if (messages == null) { - messages = loadMessages(new Locale(locale.getLanguage())); - if (messages == null) { - messages = loadMessages(null); - } + //}}} + + //{{{ initMessages() + public static void initMessages() { + if (!initialized) { + + Log.log(Log.NOTICE, Messages.class, "Loading localized messages: "+m_locale.toString()); + + m_messages = new Properties(); + + //{{{ load messages files that match the locale + + boolean hasLang = (m_locale.getLanguage() != null && !m_locale.getLanguage().equals("")); + boolean hasCountry = (m_locale.getCountry() != null && !m_locale.getCountry().equals("")); + boolean hasVariant = (m_locale.getVariant() != null && !m_locale.getVariant().equals("")); + + if (hasVariant) { + // use full locale + loadMessages(m_locale); } + + if (hasCountry) { + //use only language and country + loadMessages(new Locale(m_locale.getLanguage(), m_locale.getCountry())); + } + + if (hasLang) { + //use only the language + loadMessages(new Locale(m_locale.getLanguage())); + } + + //}}} + + // load the default messages + + loadMessages(null); + + initialized = true; } - return messages; }//}}} - //}}} + //{{{ initPluginMessages() + public static void initPluginMessages() { + if (!plugins_initialized) { + m_pluginMessages = new Properties(); + + ... [truncated message content] |
|
From: <ian...@us...> - 2006-07-10 19:13:02
|
Revision: 1004 Author: ian_lewis Date: 2006-07-10 12:12:51 -0700 (Mon, 10 Jul 2006) ViewCVS: http://svn.sourceforge.net/jsxe/?rev=1004&view=rev Log Message: ----------- Added the shortcuts option pane to the global options Modified Paths: -------------- trunk/jsxe/Changelog trunk/jsxe/messages/messages trunk/jsxe/src/net/sourceforge/jsxe/options/ShortcutsOptionPane.java Modified: trunk/jsxe/Changelog =================================================================== --- trunk/jsxe/Changelog 2006-07-08 18:22:12 UTC (rev 1003) +++ trunk/jsxe/Changelog 2006-07-10 19:12:51 UTC (rev 1004) @@ -1,3 +1,8 @@ +07/10/2006 Ian Lewis <Ian...@me...> + + * Added the Shortcuts option pane. However, it currently it doesn't work. + It only displays the built in options and the combo box. + 07/06/2006 Ian Lewis <Ian...@me...> * Rewrote the Messages class. Now it loads messages on demand and only Modified: trunk/jsxe/messages/messages =================================================================== --- trunk/jsxe/messages/messages 2006-07-08 18:22:12 UTC (rev 1003) +++ trunk/jsxe/messages/messages 2006-07-10 19:12:51 UTC (rev 1004) @@ -68,8 +68,10 @@ Global.Options.network=DTD and schema downloading: Global.Options.Menu.Spill.Over=Number of items before menus spill over - Shortcuts.Options.Title=Shortcuts +Shortcuts.Options.Select.Label=Edit Shortcuts: +Shortcuts.Options.Shortcut=Shortcut +Shortcuts.Options.Command=Command #}}} #{{{ Document Options Modified: trunk/jsxe/src/net/sourceforge/jsxe/options/ShortcutsOptionPane.java =================================================================== --- trunk/jsxe/src/net/sourceforge/jsxe/options/ShortcutsOptionPane.java 2006-07-08 18:22:12 UTC (rev 1003) +++ trunk/jsxe/src/net/sourceforge/jsxe/options/ShortcutsOptionPane.java 2006-07-10 19:12:51 UTC (rev 1004) @@ -31,14 +31,28 @@ import net.sourceforge.jsxe.ActionSet; import net.sourceforge.jsxe.ActionManager; import net.sourceforge.jsxe.gui.Messages; +import net.sourceforge.jsxe.gui.GrabKeyDialog; import net.sourceforge.jsxe.util.MiscUtilities; +import net.sourceforge.jsxe.util.Log; //}}} +//{{{ AWT classes +import java.awt.BorderLayout; +import java.awt.Dimension; +//}}} + //{{{ Swing classes +import javax.swing.Box; +import javax.swing.JLabel; +import javax.swing.JComboBox; +import javax.swing.JTable; +import javax.swing.JScrollPane; import javax.swing.table.*; //}}} //{{{ Java classses +import java.util.Comparator; +import java.util.Iterator; import java.util.Vector; //}}} @@ -67,7 +81,28 @@ //{{{ _init() protected void _init() { + setLayout(new BorderLayout(12,12)); + initModels(); + + JComboBox setsBox = new JComboBox(ActionManager.getActionSets().toArray()); + Box north = Box.createHorizontalBox(); + north.add(new JLabel(Messages.getMessage("Shortcuts.Options.Select.Label"))); + north.add(Box.createHorizontalStrut(6)); + north.add(setsBox); + + JTable keyTable = new JTable(m_currentModel); + keyTable.getTableHeader().setReorderingAllowed(false); + // keyTable.getTableHeader().addMouseListener(new HeaderMouseHandler()); + // keyTable.addMouseListener(new TableMouseHandler()); + Dimension d = keyTable.getPreferredSize(); + d.height = Math.min(d.height,200); + JScrollPane scroller = new JScrollPane(keyTable); + scroller.setPreferredSize(d); + + add(BorderLayout.NORTH,north); + add(BorderLayout.CENTER,scroller); + }//}}} //{{{ _save() @@ -82,20 +117,29 @@ //{{{ Private Members + private ActionSetTableModel m_currentModel; + private Vector m_models; + //{{{ ActionSetTableModel class private class ActionSetTableModel extends AbstractTableModel { //{{{ ActionSetTableModel constructor public ActionSetTableModel(ActionSet set) { - //TODO: need to use key bindings from the GrabKeyDialog String[] names = set.getActionNames(); m_set = new Vector(names.length); for (int i = 0; i < names.length; i++) { String label = ActionManager.getLocalizedAction(names[i]).getLabel(); - m_set.add(label); + if (label == null) { + Log.log(Log.WARNING, this, names[i]+" has a null label"); + } else { + String binding = jsXe.getProperty(names[i]+".shortcut"); + m_set.add(new GrabKeyDialog.KeyBinding(names[i], label, binding)); + } } - MiscUtilities.quicksort(m_set, new MiscUtilities.StringCompare()); + MiscUtilities.quicksort(m_set, new KeyCompare()); + + m_name = set.getLabel(); }//}}} //{{{ getColumnCount() @@ -103,6 +147,19 @@ return 2; }//}}} + //{{{ getColumnName() + + public String getColumnName(int columnIndex) { + switch (columnIndex) { + case(0): + return Messages.getMessage("Shortcuts.Options.Command"); + case(1): + return Messages.getMessage("Shortcuts.Options.Shortcut"); + default: + return null; + } + }//}}} + //{{{ getRowCount() public int getRowCount() { return m_set.size(); @@ -110,15 +167,72 @@ //{{{ getValueAt() public Object getValueAt(int row, int column) { - return null; + switch (column) { + case (0): + return ((GrabKeyDialog.KeyBinding)m_set.get(row)).label; + case (1): + return ((GrabKeyDialog.KeyBinding)m_set.get(row)).shortcut; + default: + return null; + } }//}}} + //{{{ setValueAt() + + public void setValueAt(Object value, int row, int col) { + if (col == 0) + return; + + ((GrabKeyDialog.KeyBinding)m_set.get(row)).shortcut = (String)value; + + // redraw the whole table because a second shortcut + // might have changed, too + fireTableDataChanged(); + }//}}} + + //{{{ toString() + + public String toString() { + // needed for sorting of the models in initModels() + return m_name; + }//}}} + //{{{ Private members + + //{{{ KeyCompare class + + private class KeyCompare implements Comparator { + + public int compare(Object obj1, Object obj2) { + String label1 = ((GrabKeyDialog.KeyBinding)obj1).label; + String label2 = ((GrabKeyDialog.KeyBinding)obj2).label; + return MiscUtilities.compareStrings(label1,label2,true); + } + + }//}}} + private Vector m_set; + private String m_name; //}}} }//}}} + //{{{ initModels() + + private void initModels() { + m_models = new Vector(); + Iterator itr = ActionManager.getActionSets().iterator(); + while(itr.hasNext()) { + ActionSet actionSet = (ActionSet)itr.next(); + if (actionSet.getActionCount() != 0) { + String modelLabel = actionSet.getLabel(); + m_models.addElement(new ActionSetTableModel(actionSet)); + } + } + MiscUtilities.quicksort(m_models,new MiscUtilities.StringICaseCompare()); + m_currentModel = (ActionSetTableModel)m_models.elementAt(0); + }//}}} + //}}} } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
|
From: <ian...@us...> - 2006-07-11 03:47:03
|
Revision: 1006 Author: ian_lewis Date: 2006-07-10 20:46:50 -0700 (Mon, 10 Jul 2006) ViewCVS: http://svn.sourceforge.net/jsxe/?rev=1006&view=rev Log Message: ----------- Added code for displaying the grab key dialog Modified Paths: -------------- trunk/jsxe/Changelog trunk/jsxe/src/net/sourceforge/jsxe/ActionManager.java trunk/jsxe/src/net/sourceforge/jsxe/gui/GrabKeyDialog.java trunk/jsxe/src/net/sourceforge/jsxe/properties Modified: trunk/jsxe/Changelog =================================================================== --- trunk/jsxe/Changelog 2006-07-11 00:14:33 UTC (rev 1005) +++ trunk/jsxe/Changelog 2006-07-11 03:46:50 UTC (rev 1006) @@ -2,6 +2,8 @@ * Added the Shortcuts option pane. However, it currently it doesn't work. It only displays the built in options and the combo box. + * Updated the shortcuts option pane so that it shows the select shortcut + dialog. 07/06/2006 Ian Lewis <Ian...@me...> Modified: trunk/jsxe/src/net/sourceforge/jsxe/ActionManager.java =================================================================== --- trunk/jsxe/src/net/sourceforge/jsxe/ActionManager.java 2006-07-11 00:14:33 UTC (rev 1005) +++ trunk/jsxe/src/net/sourceforge/jsxe/ActionManager.java 2006-07-11 03:46:50 UTC (rev 1006) @@ -224,7 +224,8 @@ //{{{ addKeyBinding() /** * Adds a key binding to this input handler. - * @param keyBinding The key binding + * @param keyBinding The key binding. It should be of the form described + * in {@link net.sourceforge.jsxe.gui.KeyEventTranslator} * @param action The action */ public static void addKeyBinding(String keyBinding, LocalizedAction action) { Modified: trunk/jsxe/src/net/sourceforge/jsxe/gui/GrabKeyDialog.java =================================================================== --- trunk/jsxe/src/net/sourceforge/jsxe/gui/GrabKeyDialog.java 2006-07-11 00:14:33 UTC (rev 1005) +++ trunk/jsxe/src/net/sourceforge/jsxe/gui/GrabKeyDialog.java 2006-07-11 03:46:50 UTC (rev 1006) @@ -112,20 +112,19 @@ * removed or the dialog either has been cancelled. Use isOK() * to determine if the latter is true. */ - public String getShortcut() - { - if(isOK) + public String getShortcut() { + if (isOK) { return shortcut.getText(); - else + } else { return null; + } } //}}} //{{{ isOK() method /** * Returns true, if the dialog has not been cancelled. */ - public boolean isOK() - { + public boolean isOK() { return isOK; } //}}} @@ -296,38 +295,49 @@ if (ok != null) { ok.setEnabled(kb == null/* || !kb.isPrefix*/); } - + assignedTo.setText(Messages.getMessage("Grab.Key.assigned-to", new String[] { text })); } //}}} //{{{ getKeyBinding() method - private KeyBinding getKeyBinding(String shortcut) - { - if(shortcut == null || shortcut.length() == 0) + private KeyBinding getKeyBinding(String shortcut) { + + if (shortcut == null || shortcut.length() == 0) { return null; - - String spacedShortcut = shortcut + " "; + } + + Log.log(Log.DEBUG, this, "getting key binding for: "+shortcut); + + // String spacedShortcut = shortcut + " "; Enumeration e = allBindings.elements(); - while(e.hasMoreElements()) - { + while (e.hasMoreElements()) { + KeyBinding kb = (KeyBinding)e.nextElement(); - - if(!kb.isAssigned()) + + if (!kb.isAssigned()) { continue; - - String spacedKbShortcut = kb.shortcut + " "; - + } + + // String spacedKbShortcut = kb.shortcut + " "; + + Log.log(Log.DEBUG, this, "searching "+kb.label+": "+kb.shortcut); + // eg, trying to bind C+n C+p if C+n already bound - if(spacedShortcut.startsWith(spacedKbShortcut)) + // if (spacedShortcut.startsWith(spacedKbShortcut)) { + // return kb; + // } + + if (shortcut.equals(kb.shortcut)) { return kb; - + } + // eg, trying to bind C+e if C+e is a prefix - if(spacedKbShortcut.startsWith(spacedShortcut)) { - // create a temporary (synthetic) prefix - // KeyBinding, that won't be saved - return new KeyBinding(kb.name,kb.label,shortcut); - } + // if (spacedKbShortcut.startsWith(spacedShortcut)) { + // // create a temporary (synthetic) prefix + // // KeyBinding, that won't be saved + // return new KeyBinding(kb.name,kb.label,shortcut); + // } } return null; @@ -369,9 +379,9 @@ } //}}} //{{{ processKeyEvent() method - protected void processKeyEvent(KeyEvent evt) { - // KeyEvent evt = KeyEventWorkaround.processKeyEvent(_evt); - // Log.log(Log.DEBUG, this, "Event " + GrabKeyDialog.toString(_evt) + (evt == null ? " filtered\n" : " passed\n")); + protected void processKeyEvent(KeyEvent _evt) { + KeyEvent evt = KeyEventWorkaround.processKeyEvent(_evt); + Log.log(Log.DEBUG, this, "Event " + GrabKeyDialog.toString(_evt) + (evt == null ? " filtered\n" : " passed\n")); if (evt == null) { return; @@ -379,41 +389,33 @@ evt.consume(); - // KeyEventTranslator.Key key = KeyEventTranslator.translateKeyEvent(evt); - // if (key == null) { - // return; - // } + KeyEventTranslator.Key key = KeyEventTranslator.translateKeyEvent(evt); + if (key == null) { + return; + } - // Log.log(Log.DEBUG, this, "==> Translated to " + key + "\n"); + Log.log(Log.DEBUG, this, "==> Translated to " + key + "\n"); - StringBuffer keyString = new StringBuffer(getText()); + StringBuffer keyString = new StringBuffer(); - // if (getDocument().getLength() != 0) { - // keyString.append(' '); - // } - - // if (key.modifiers != null) { - // keyString.append(key.modifiers).append('+'); - // } - - if (evt.getModifiers() != 0) { - keyString.append(KeyEvent.getKeyModifiersText(evt.getModifiers())).append(' '); + if (key.modifiers != null) { + keyString.append(key.modifiers).append('+'); } - if (evt.getKeyCode() == KeyEvent.VK_SPACE) { + if (key.input == ' ') { keyString.append("SPACE"); } else { - // if (key.input != '\0') { - keyString.append(KeyEvent.getKeyText(evt.getKeyCode())); - // } else { - // String symbolicName = getSymbolicName(key.key); + if (key.input != '\0') { + keyString.append(key.input); + } else { + String symbolicName = getSymbolicName(key.key); - // if (symbolicName == null) { - // return; - // } + if (symbolicName == null) { + return; + } - // keyString.append(symbolicName); - // } + keyString.append(symbolicName); + } } setText(keyString.toString()); Modified: trunk/jsxe/src/net/sourceforge/jsxe/properties =================================================================== --- trunk/jsxe/src/net/sourceforge/jsxe/properties 2006-07-11 00:14:33 UTC (rev 1005) +++ trunk/jsxe/src/net/sourceforge/jsxe/properties 2006-07-11 03:46:50 UTC (rev 1006) @@ -52,7 +52,7 @@ #}}} #{{{ Default key bindings -open-file.shortcut=ctrl O +open-file.shortcut=ctrl ENTER exit.shortcut=ctrl Q close-file.shortcut=ctrl W new-file.shortcut=ctrl N This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
|
From: <ian...@us...> - 2006-07-12 17:23:47
|
Revision: 1017 Author: ian_lewis Date: 2006-07-12 10:23:27 -0700 (Wed, 12 Jul 2006) ViewCVS: http://svn.sourceforge.net/jsxe/?rev=1017&view=rev Log Message: ----------- Added funcionality to save keyboard shortcuts. Modified Paths: -------------- trunk/jsxe/Changelog trunk/jsxe/src/net/sourceforge/jsxe/gui/TabbedView.java trunk/jsxe/src/net/sourceforge/jsxe/options/ShortcutsOptionPane.java Modified: trunk/jsxe/Changelog =================================================================== --- trunk/jsxe/Changelog 2006-07-12 16:40:31 UTC (rev 1016) +++ trunk/jsxe/Changelog 2006-07-12 17:23:27 UTC (rev 1017) @@ -1,3 +1,10 @@ +07/12/2006 Ian Lewis <Ian...@me...> + + * Added functionality to save keyboard shortcuts. The shortcuts themselves + work but the shortcut labels for menu items are not updated when the + action is updated. This is a bug that is fixed in the beta for Java 6 + but obviously it can't wait that long. + 07/10/2006 Ian Lewis <Ian...@me...> * Added the Shortcuts option pane. However, it currently it doesn't work. Modified: trunk/jsxe/src/net/sourceforge/jsxe/gui/TabbedView.java =================================================================== --- trunk/jsxe/src/net/sourceforge/jsxe/gui/TabbedView.java 2006-07-12 16:40:31 UTC (rev 1016) +++ trunk/jsxe/src/net/sourceforge/jsxe/gui/TabbedView.java 2006-07-12 17:23:27 UTC (rev 1017) @@ -325,7 +325,7 @@ */ protected void processKeyEvent(KeyEvent e) { //TODO: process shortcuts - Log.log(Log.DEBUG, this, e.toString()); + // Log.log(Log.DEBUG, this, e.toString()); ActionManager.handleKey(e); }//}}} Modified: trunk/jsxe/src/net/sourceforge/jsxe/options/ShortcutsOptionPane.java =================================================================== --- trunk/jsxe/src/net/sourceforge/jsxe/options/ShortcutsOptionPane.java 2006-07-12 16:40:31 UTC (rev 1016) +++ trunk/jsxe/src/net/sourceforge/jsxe/options/ShortcutsOptionPane.java 2006-07-12 17:23:27 UTC (rev 1017) @@ -111,7 +111,14 @@ //{{{ _save() protected void _save() { - + if (m_keyTable.getCellEditor() != null) { + m_keyTable.getCellEditor().stopCellEditing(); + } + + Iterator e = m_models.iterator(); + while (e.hasNext()) { + ((ActionSetTableModel)e.next()).save(); + } }//}}} //{{{ toString() @@ -153,7 +160,7 @@ //{{{ getBindingAt() public GrabKeyDialog.KeyBinding getBindingAt(int row) { - return (GrabKeyDialog.KeyBinding)m_set.elementAt(row); + return (GrabKeyDialog.KeyBinding)m_set.elementAt(row); }//}}} //{{{ getColumnCount() @@ -225,6 +232,19 @@ return m_name; }//}}} + //{{{ save() + /** + * Saves the current config to the properties + */ + public void save() { + Iterator e = m_set.iterator(); + while(e.hasNext()) { + GrabKeyDialog.KeyBinding binding = (GrabKeyDialog.KeyBinding)e.next(); + + jsXe.setProperty(binding.name + ".shortcut", binding.shortcut); + } + }//}}} + //{{{ Private members //{{{ KeyCompare class @@ -281,7 +301,6 @@ }//}}} //{{{ initModels() - private void initModels() { m_models = new Vector(); Iterator itr = ActionManager.getActionSets().iterator(); @@ -317,4 +336,4 @@ //}}} -} +} \ No newline at end of file This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
|
From: <ian...@us...> - 2006-07-12 20:07:52
|
Revision: 1022 Author: ian_lewis Date: 2006-07-12 13:07:44 -0700 (Wed, 12 Jul 2006) ViewCVS: http://svn.sourceforge.net/jsxe/?rev=1022&view=rev Log Message: ----------- Messages loads messages files in UTF-8 Modified Paths: -------------- trunk/jsxe/Changelog trunk/jsxe/messages/messages trunk/jsxe/src/net/sourceforge/jsxe/gui/Messages.java Modified: trunk/jsxe/Changelog =================================================================== --- trunk/jsxe/Changelog 2006-07-12 17:53:33 UTC (rev 1021) +++ trunk/jsxe/Changelog 2006-07-12 20:07:44 UTC (rev 1022) @@ -5,6 +5,7 @@ action is updated. This is a bug that is fixed in the beta for Java 6 but obviously it can't wait that long. * Renamed EnhancedMenu to WrappingMenu. I think it's more descriptive. + * Updated messages to load the messages files in UTF-8 07/10/2006 Ian Lewis <Ian...@me...> Modified: trunk/jsxe/messages/messages =================================================================== --- trunk/jsxe/messages/messages 2006-07-12 17:53:33 UTC (rev 1021) +++ trunk/jsxe/messages/messages 2006-07-12 20:07:44 UTC (rev 1022) @@ -25,6 +25,11 @@ common.find=Find... common.findnext=Find Next +common.ctrl=Ctrl +common.alt=Alt +common.shift=Shift +common.meta=Meta + #}}} #{{{ XML Terminology Modified: trunk/jsxe/src/net/sourceforge/jsxe/gui/Messages.java =================================================================== --- trunk/jsxe/src/net/sourceforge/jsxe/gui/Messages.java 2006-07-12 17:53:33 UTC (rev 1021) +++ trunk/jsxe/src/net/sourceforge/jsxe/gui/Messages.java 2006-07-12 20:07:44 UTC (rev 1022) @@ -75,10 +75,6 @@ public class Messages { //{{{ Private static members - /* - TODO: Properties files save and load in ISO 8859-1. This is unacceptable. - Need a UTF-8 way to load properties. - */ /** * properties containing the messages for jsXe */ @@ -88,8 +84,13 @@ */ private static Properties m_pluginMessages; + static { + // Locale.setDefault(new Locale("sv")); + Locale.setDefault(Locale.GERMANY); + } private static Locale m_locale = Locale.getDefault(); + private static boolean initialized = false; private static boolean plugins_initialized = false; @@ -124,6 +125,7 @@ String messagesFile = getMessagesFileName(locale); try { + Properties props = new Properties(); //create input stream from messages file FileInputStream in = new FileInputStream(jsXe.getInstallDirectory()+ @@ -132,12 +134,23 @@ System.getProperty("file.separator")+ messagesFile); - Properties props = new Properties(); - Log.log(Log.NOTICE, Messages.class, "Loading message file: "+messagesFile); props.load(in); + //reset the messages in UTF-8 + //TODO: fix this so we don't have to do a encoding conversion + Enumeration keys = props.keys(); + while (keys.hasMoreElements()) { + String key = keys.nextElement().toString(); + String value = props.getProperty(key); + if (value != null) { + props.setProperty(key, new String(value.getBytes("ISO-8859-1"),"UTF-8")); + } else { + Log.log(Log.DEBUG, Messages.class, "null value: "+key); + } + } + m_messages = MiscUtilities.mergeProperties(m_messages, props); } catch (FileNotFoundException e) { @@ -166,6 +179,19 @@ props.load(resource.openStream()); + //reset the messages in UTF-8 + //TODO: fix this so we don't have to do a encoding conversion + Enumeration keys = props.keys(); + while (keys.hasMoreElements()) { + String key = keys.nextElement().toString(); + String value = props.getProperty(key); + if (value != null) { + props.setProperty(key, new String(value.getBytes("ISO-8859-1"),"UTF-8")); + } else { + Log.log(Log.DEBUG, Messages.class, "null value: "+key); + } + } + m_pluginMessages = MiscUtilities.mergeProperties(m_pluginMessages, props); } catch (FileNotFoundException e) { //fall through This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
|
From: <ian...@us...> - 2006-07-12 22:18:49
|
Revision: 1024 Author: ian_lewis Date: 2006-07-12 15:18:39 -0700 (Wed, 12 Jul 2006) ViewCVS: http://svn.sourceforge.net/jsxe/?rev=1024&view=rev Log Message: ----------- Updated the build process to run native2ascii on message files Modified Paths: -------------- trunk/jsxe/build.xml trunk/jsxe/src/net/sourceforge/jsxe/gui/Messages.java trunk/jsxe/src/net/sourceforge/jsxe/jsXe.java Modified: trunk/jsxe/build.xml =================================================================== --- trunk/jsxe/build.xml 2006-07-12 20:10:38 UTC (rev 1023) +++ trunk/jsxe/build.xml 2006-07-12 22:18:39 UTC (rev 1024) @@ -31,12 +31,12 @@ <property name="build.messages" value="${build.dir}/messages"/> <property name="docs.dir" value="${src.dir}/doc"/> <property name="plugin.dir" value="${root.dir}/jars"/> + <property name="build.plugin" value="${build.dir}/jars"/> <property name="build.src" value="${build.dir}/src"/> <property name="build.dest" value="${build.dir}/classes"/> <property name="build.docs" value="${build.dir}/doc"/> <property name="build.lib" value="${build.dir}/lib"/> <property name="build.bin" value="${build.dir}/bin"/> - <property name="build.bin" value="${build.dir}/bin"/> <property name="date.format" value="MM.dd.yyyy HH:mm:ss z"/> <property name="build.javadocs" value="${build.docs}/api"/> <property name="build.help" value="${build.docs}/help"/> @@ -71,7 +71,7 @@ </path> <path id="run-classpath"> - <pathelement location="${root.dir}/${app.name}.jar"/> + <pathelement location="${build.dir}/${app.name}.jar"/> <fileset dir="${lib.dir}"> <include name="**/*.jar"/> </fileset> @@ -127,12 +127,23 @@ <include name="**/*.png"/> </fileset> </copy> + <mkdir dir="${build.plugin}"/> + + <copy todir="${build.plugin}"> + <fileset dir="${plugin.dir}"> + <include name="**/*"/> + </fileset> + </copy> + <mkdir dir="${build.messages}"/> - <copy todir="${build.messages}"> + <!--<copy todir="${build.messages}"> <fileset dir="${messages.dir}"> <include name="**/messages.*"/> </fileset> - </copy> + </copy>--> + + <!-- run native2ascii on these files --> + <native2ascii encoding="UTF-8" src="${messages.dir}" dest="${build.messages}" includes="messages*"/> </target> <!-- }}} --> <!-- {{{ ============ Compiles the program ============================= --> @@ -166,7 +177,7 @@ </propertyfile> <!-- create jar manifest --> - <manifest file="${root.dir}/${app.name}.manifest"> + <manifest file="${build.dir}/${app.name}.manifest"> <attribute name="Built-By" value="${user.name}"/> <attribute name="Main-Class" value="${main.class}"/> <section name="common"> @@ -175,7 +186,7 @@ </section> </manifest> - <jar jarfile="${root.dir}/${app.name}.jar" manifest="${app.name}.manifest"> + <jar jarfile="${build.dir}/${app.name}.jar" manifest="${build.dir}/${app.name}.manifest"> <fileset dir="${build.dest}"> <include name="**/*.class"/> <include name="**/properties"/> @@ -194,16 +205,16 @@ <antcall target="build-sourceview"/> </target> <target name="build-treeview" if="treeview.avail"> - <ant inheritAll="false" dir="${plugin.dir}/treeview/" target="compile"/> + <ant inheritAll="false" dir="${build.plugin}/treeview/" target="compile"/> </target> <target name="build-sourceview" if="sourceview.avail"> - <ant inheritAll="false" dir="${plugin.dir}/sourceview/" target="compile"/> + <ant inheritAll="false" dir="${build.plugin}/sourceview/" target="compile"/> </target> <!-- }}} --> <!-- {{{ ============ Run the program ================================== --> <target depends="compile" name="run" description="run jsXe"> <java fork="true" classname="${main.class}"> - <classpath refid="classpath"/> + <classpath refid="run-classpath"/> </java> </target> <!-- }}} --> @@ -248,7 +259,7 @@ <!-- plugins --> <mkdir dir="${distbin.dir}/jars"/> <copy todir="${distbin.dir}/jars"> - <fileset dir="${plugin.dir}"> + <fileset dir="${build.plugin}"> <include name="*.jar"/> </fileset> </copy> @@ -272,11 +283,11 @@ <mkdir dir="${distbin.dir}/messages"/> <copy todir="${distbin.dir}/messages"> <fileset dir="${build.messages}"> - <include name="**/messages.*"/> + <include name="**/messages*"/> </fileset> </copy> - <copy file="${app.name}.jar" tofile="${distbin.dir}/${app.name}.jar"/> + <copy file="${build.dir}/${app.name}.jar" tofile="${distbin.dir}/${app.name}.jar"/> <!-- lib --> <mkdir dir="${distbin.dir}/lib"/> <copy todir="${distbin.dir}/lib"> @@ -331,7 +342,7 @@ <mkdir dir="${distsrc.dir}/messages"/> <copy todir="${distsrc.dir}/messages"> <fileset dir="${build.messages}"> - <include name="**/messages.*"/> + <include name="**/messages*"/> </fileset> </copy> @@ -339,7 +350,7 @@ </target> <target name="copy-treeview-source" if="treeview.avail"> <copy todir="${distsrc.dir}/jars"> - <fileset dir="${root.dir}/jars/"> + <fileset dir="${build.dir}/jars/"> <include name="treeview/**/*"/> <exclude name="treeview/build"/> <exclude name="treeview/build/**/*"/> @@ -349,7 +360,7 @@ </target> <target name="copy-sourceview-source" if="sourceview.avail"> <copy todir="${distsrc.dir}/jars"> - <fileset dir="${root.dir}/jars/"> + <fileset dir="${build.dir}/jars/"> <include name="sourceview/**/*"/> <exclude name="sourceview/build"/> <exclude name="sourceview/build/**/*"/> @@ -367,8 +378,6 @@ <target depends="init" name="clean" description="Clean up distribution tree"> <delete dir="${build.dir}"/> <delete> - <fileset dir="." includes="${app.name}.jar"/> - <fileset dir="." includes="${app.name}.manifest"/> <fileset dir="." includes="**/*.class"/> <fileset dir="." includes="**/*.rej"/> <fileset dir="." includes="**/*.orig"/> @@ -378,14 +387,14 @@ <fileset dir="." includes="**/.directory"/> <fileset dir="." includes="**/.xvpics"/> </delete> - <antcall target="clean-treeview"/> - <antcall target="clean-sourceview"/> + <!--<antcall target="clean-treeview"/>--> + <!--<antcall target="clean-sourceview"/>--> </target> - <target name="clean-treeview" if="treeview.avail"> + <!--<target name="clean-treeview" if="treeview.avail"> <ant inheritAll="false" dir="${plugin.dir}/treeview/" target="clean"/> </target> <target name="clean-sourceview" if="sourceview.avail"> <ant inheritAll="false" dir="${plugin.dir}/sourceview/" target="clean"/> - </target> + </target>--> <!-- }}} --> </project> Modified: trunk/jsxe/src/net/sourceforge/jsxe/gui/Messages.java =================================================================== --- trunk/jsxe/src/net/sourceforge/jsxe/gui/Messages.java 2006-07-12 20:10:38 UTC (rev 1023) +++ trunk/jsxe/src/net/sourceforge/jsxe/gui/Messages.java 2006-07-12 22:18:39 UTC (rev 1024) @@ -59,6 +59,12 @@ * names with the format messages.<code>language</code>.<code>country</code>.<code>variant</code>. * The Messages class searches these files in the following order. * + * Messages files should be in a format that the <code>Properties</code> class + * can understand. This means that messages files that contain localized + * characters should have the native2ascii tool run on them. This ensures + * that these characters are in the \\u... format that can be read by the + * <code>Properties</code> class. + * * <ul> * <li>messages.<code>language</code>_<code>country</code>_<code>variant</code></li> * <li>messages.<code>language</code>_<code>country</code></li> @@ -84,10 +90,11 @@ */ private static Properties m_pluginMessages; - // static { - // // Locale.setDefault(new Locale("sv")); - // Locale.setDefault(Locale.GERMANY); - // } + static { + // Locale.setDefault(new Locale("sv")); + Locale.setDefault(Locale.GERMANY); + // Locale.setDefault(Locale.JAPAN); + } private static Locale m_locale = Locale.getDefault(); @@ -140,16 +147,16 @@ //reset the messages in UTF-8 //TODO: fix this so we don't have to do a encoding conversion - Enumeration keys = props.keys(); - while (keys.hasMoreElements()) { - String key = keys.nextElement().toString(); - String value = props.getProperty(key); - if (value != null) { - props.setProperty(key, new String(value.getBytes("ISO-8859-1"),"UTF-8")); - } else { - Log.log(Log.DEBUG, Messages.class, "null value: "+key); - } - } + // Enumeration keys = props.keys(); + // while (keys.hasMoreElements()) { + // String key = keys.nextElement().toString(); + // String value = props.getProperty(key); + // if (value != null) { + // props.setProperty(key, new String(value.getBytes("ISO-8859-1"),"UTF-8")); + // } else { + // Log.log(Log.DEBUG, Messages.class, "null value: "+key); + // } + // } m_messages = MiscUtilities.mergeProperties(m_messages, props); @@ -181,16 +188,16 @@ //reset the messages in UTF-8 //TODO: fix this so we don't have to do a encoding conversion - Enumeration keys = props.keys(); - while (keys.hasMoreElements()) { - String key = keys.nextElement().toString(); - String value = props.getProperty(key); - if (value != null) { - props.setProperty(key, new String(value.getBytes("ISO-8859-1"),"UTF-8")); - } else { - Log.log(Log.DEBUG, Messages.class, "null value: "+key); - } - } + // Enumeration keys = props.keys(); + // while (keys.hasMoreElements()) { + // String key = keys.nextElement().toString(); + // String value = props.getProperty(key); + // if (value != null) { + // props.setProperty(key, new String(value.getBytes("ISO-8859-1"),"UTF-8")); + // } else { + // Log.log(Log.DEBUG, Messages.class, "null value: "+key); + // } + // } m_pluginMessages = MiscUtilities.mergeProperties(m_pluginMessages, props); } catch (FileNotFoundException e) { Modified: trunk/jsxe/src/net/sourceforge/jsxe/jsXe.java =================================================================== --- trunk/jsxe/src/net/sourceforge/jsxe/jsXe.java 2006-07-12 20:10:38 UTC (rev 1023) +++ trunk/jsxe/src/net/sourceforge/jsxe/jsXe.java 2006-07-12 22:18:39 UTC (rev 1024) @@ -140,6 +140,7 @@ } } } + System.out.println(jsXeHome); //}}} This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
|
From: <ian...@us...> - 2006-07-20 16:50:19
|
Revision: 1042 Author: ian_lewis Date: 2006-07-20 09:50:11 -0700 (Thu, 20 Jul 2006) ViewCVS: http://svn.sourceforge.net/jsxe/?rev=1042&view=rev Log Message: ----------- Updated for 0.5 pre1 release Modified Paths: -------------- trunk/jsxe/Changelog trunk/jsxe/NEWS trunk/jsxe/RELEASE.CHECKLIST Modified: trunk/jsxe/Changelog =================================================================== --- trunk/jsxe/Changelog 2006-07-20 16:27:04 UTC (rev 1041) +++ trunk/jsxe/Changelog 2006-07-20 16:50:11 UTC (rev 1042) @@ -1,5 +1,6 @@ 07/20/2006 Ian Lewis <Ian...@me...> + * Released 0.5pre1 * Keyboard shortcuts are now fully supported. * Added Japanese translation Modified: trunk/jsxe/NEWS =================================================================== --- trunk/jsxe/NEWS 2006-07-20 16:27:04 UTC (rev 1041) +++ trunk/jsxe/NEWS 2006-07-20 16:50:11 UTC (rev 1042) @@ -1,3 +1,16 @@ +07/25/2006 version 0.5 pre1 + + * Added support for keyboard shortcuts that can be set by the user via + the Global Options Dialog. + * Split the options into two dialogs. The Global Options, which are + editor-wide options, and the Document Options, which are set for each + document. + * Added a Japanese translation. + * Added a British-English translation. + * Fixed translation files so that non-ASCII characters will be displayed + properly. + * Added a status bar to display messages to the user. + 04/25/2006 version 0.4 beta * Updated to work with xerces 2.8.0 (jsXe now requires xerces 2.8.0) Modified: trunk/jsxe/RELEASE.CHECKLIST =================================================================== --- trunk/jsxe/RELEASE.CHECKLIST 2006-07-20 16:27:04 UTC (rev 1041) +++ trunk/jsxe/RELEASE.CHECKLIST 2006-07-20 16:50:11 UTC (rev 1042) @@ -1,5 +1,7 @@ RELEASE CHECKLIST +* Make sure all bugs that are priority 5 or higher are resolved. + * Get translations finalized * Build the Java Doc and check it for omissions and errors. @@ -8,7 +10,6 @@ * Update the README if needed * Update the AUTHORS if needed * Update the INSTALL file if needed -* Update the README if needed * Update the jsXe website in CVS to reference the new versions * Update the jsXe website in CVS to have the correct help and documentation. * Run 'ant deploy-web-doc' 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:44:27
|
Revision: 1047 Author: ian_lewis Date: 2006-07-20 16:44:21 -0700 (Thu, 20 Jul 2006) ViewCVS: http://svn.sourceforge.net/jsxe/?rev=1047&view=rev Log Message: ----------- fixed minor build issues Modified Paths: -------------- trunk/jsxe/build.xml Added Paths: ----------- trunk/jsxe/lib/ Modified: trunk/jsxe/build.xml =================================================================== --- trunk/jsxe/build.xml 2006-07-20 21:56:11 UTC (rev 1046) +++ trunk/jsxe/build.xml 2006-07-20 23:44:21 UTC (rev 1047) @@ -81,6 +81,7 @@ <available file="${plugin.dir}/treeview/build.xml" property="treeview.avail"/> <available file="${plugin.dir}/sourceview/build.xml" property="sourceview.avail"/> <available file="${root.dir}/../web" property="web.avail"/> + <available file="${plugin.dir}" property="plugin.avail"/> <echo message="${app.name} ${app.version}"/> <echo message="----------------------------------------------------------"/> @@ -129,11 +130,7 @@ </copy> <mkdir dir="${build.plugin}"/> - <copy todir="${build.plugin}"> - <fileset dir="${plugin.dir}"> - <include name="**/*"/> - </fileset> - </copy> + <antcall target="prepare-plugins"/> <mkdir dir="${build.messages}"/> <!--<copy todir="${build.messages}"> @@ -145,6 +142,13 @@ <!-- run native2ascii on these files --> <native2ascii encoding="UTF-8" src="${messages.dir}" dest="${build.messages}" includes="messages*"/> </target> + <target name="prepare-plugins" if="plugin.avail"> + <copy todir="${build.plugin}"> + <fileset dir="${plugin.dir}"> + <include name="**/*"/> + </fileset> + </copy> + </target> <!-- }}} --> <!-- {{{ ============ Compiles the program ============================= --> <target depends="prepare-src" name="compile" description="compile jsXe"> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
|
From: <ian...@us...> - 2006-07-21 16:19:17
|
Revision: 1049 Author: ian_lewis Date: 2006-07-21 09:19:06 -0700 (Fri, 21 Jul 2006) ViewCVS: http://svn.sourceforge.net/jsxe/?rev=1049&view=rev Log Message: ----------- Fixed bug 1509575 Modified Paths: -------------- trunk/jsxe/Changelog trunk/jsxe/messages/messages trunk/jsxe/src/net/sourceforge/jsxe/action/FileReloadAction.java trunk/jsxe/src/net/sourceforge/jsxe/gui/TabbedView.java Modified: trunk/jsxe/Changelog =================================================================== --- trunk/jsxe/Changelog 2006-07-20 23:46:29 UTC (rev 1048) +++ trunk/jsxe/Changelog 2006-07-21 16:19:06 UTC (rev 1049) @@ -1,3 +1,8 @@ +07/21/2006 Ian Lewis <Ian...@me...> + + * Fixed bug 1509575. Files that are reloaded should always be loaded in a + view that can accep the reloaded file. + 07/20/2006 Ian Lewis <Ian...@me...> * Released 0.5pre1 Modified: trunk/jsxe/messages/messages =================================================================== --- trunk/jsxe/messages/messages 2006-07-20 23:46:29 UTC (rev 1048) +++ trunk/jsxe/messages/messages 2006-07-21 16:19:06 UTC (rev 1049) @@ -163,6 +163,8 @@ #{{{ Messages +DocumentView.Open.Message="Could not open buffer in any installed document views" + #{0} file name DocumentBuffer.Reload.Message={0} unsaved!\n You will lose all unsaved changes if you reload!\n\nContinue? DocumentBuffer.Reload.Message.Title=Document Modified Modified: trunk/jsxe/src/net/sourceforge/jsxe/action/FileReloadAction.java =================================================================== --- trunk/jsxe/src/net/sourceforge/jsxe/action/FileReloadAction.java 2006-07-20 23:46:29 UTC (rev 1048) +++ trunk/jsxe/src/net/sourceforge/jsxe/action/FileReloadAction.java 2006-07-21 16:19:06 UTC (rev 1049) @@ -66,10 +66,7 @@ //{{{ invoke() public void invoke(TabbedView view, ActionEvent evt) { try { - DocumentView documentView = view.getDocumentView(); - DocumentBuffer buffer = view.getDocumentBuffer(); - buffer.reload(view); - documentView.setDocumentBuffer(buffer); //reload the buffer in the documentView + view.reload(); } catch (IOException ioe) { JOptionPane.showMessageDialog(view, ioe, Messages.getMessage("IO.Error.title"), JOptionPane.WARNING_MESSAGE); } Modified: trunk/jsxe/src/net/sourceforge/jsxe/gui/TabbedView.java =================================================================== --- trunk/jsxe/src/net/sourceforge/jsxe/gui/TabbedView.java 2006-07-20 23:46:29 UTC (rev 1048) +++ trunk/jsxe/src/net/sourceforge/jsxe/gui/TabbedView.java 2006-07-21 16:19:06 UTC (rev 1049) @@ -33,7 +33,7 @@ //{{{ jsXe classes import net.sourceforge.jsxe.*; -import net.sourceforge.jsxe.msg.PropertyChanged; +import net.sourceforge.jsxe.msg.*; import net.sourceforge.jsxe.action.*; import net.sourceforge.jsxe.gui.menu.*; import net.sourceforge.jsxe.util.Log; @@ -201,7 +201,7 @@ } } - String msg = "Could not open buffer in any installed document views"; + String msg = Messages.getMessage("DocumentView.Open.Message"); String error = buf.toString(); if (!error.equals("")) { msg=msg+"\n\n"+error; @@ -267,6 +267,56 @@ return false; }//}}} + //{{{ reload() + /** + * Reloads the current DocumentBuffer and makes sure that the + * reloaded document is opened in an appropriate DocumentView. + * @param buffer the DocumentBuffer to reload. + */ + public void reload() throws IOException { + DocumentBuffer buffer = getDocumentBuffer(); + ViewPlugin plugin = getDocumentView().getViewPlugin(); + + /* + try to open it in the current view first. If that doesn't work + loop through the other views + */ + + StringBuffer buf = new StringBuffer(); + + buffer.reload(this); + + try { + DocumentView view = plugin.newDocumentView(buffer); + setDocumentView(view); + return; + } catch (IOException ioe) { + + buf.append(buffer.getName() + ": "+ioe.getMessage() + "\n"); + + Iterator types = jsXe.getPluginLoader().getViewPlugins().iterator(); + + while (types.hasNext()) { + plugin = (ViewPlugin)types.next(); + try { + DocumentView view = plugin.newDocumentView(buffer); + setDocumentView(view); + return; + } catch (IOException ioe2) { + buf.append(buffer.getName() + ": "+ioe.getMessage() + "\n"); + } + } + } + + String msg = Messages.getMessage("DocumentView.Open.Message"); + String error = buf.toString(); + if (!error.equals("")) { + msg=msg+"\n\n"+error; + } + throw new IOException(msg); + + }//}}} + //{{{ getBufferCount() /** * Gets the number of open buffers. @@ -501,6 +551,17 @@ updateMenuBar(); } } + + /* + Catch when a document is reloaded and make sure the view + can still handle the structure.. + */ + if (message instanceof DocumentBufferUpdate) { + DocumentBufferUpdate msg = (DocumentBufferUpdate)message; + if (DocumentBufferUpdate.LOADED.equals(msg.getWhat())) { + + } + } } }); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |