[Jsxe-cvs] SF.net SVN: jsxe: [966] trunk/jsxe
Status: Inactive
Brought to you by:
ian_lewis
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) { + //{{{ invoke() + public void invoke(TabbedView view, ActionEvent evt) { new DocumentOptionsDialog(view); }//}}} - //{{{ Private members - private TabbedView view; - //}}} } Modified: trunk/jsxe/src/net/sourceforge/jsxe/action/FileCloseAction.java =================================================================== --- trunk/jsxe/src/net/sourceforge/jsxe/action/FileCloseAction.java 2006-06-15 21:52:24 UTC (rev 965) +++ trunk/jsxe/src/net/sourceforge/jsxe/action/FileCloseAction.java 2006-06-20 19:29:38 UTC (rev 966) @@ -26,15 +26,10 @@ 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.jsXe; -import net.sourceforge.jsxe.gui.Messages; +import net.sourceforge.jsxe.LocalizedAction; import net.sourceforge.jsxe.gui.TabbedView; //}}} @@ -43,9 +38,6 @@ //}}} //{{{ Swing components -import javax.swing.Action; -import javax.swing.AbstractAction; -import javax.swing.KeyStroke; import javax.swing.JOptionPane; //}}} @@ -62,28 +54,21 @@ * @author Trish Hartnett (<a href="mailto:tri...@me...">tri...@me...</a>) * @version $Id$ */ -public class FileCloseAction extends AbstractAction { +public class FileCloseAction extends LocalizedAction { //{{{ FileCloseAction constructor - public FileCloseAction(TabbedView parent) { - //putValue(Action.NAME, "Close"); - putValue(Action.NAME, Messages.getMessage("File.Close")); - putValue(Action.ACCELERATOR_KEY,KeyStroke.getKeyStroke("ctrl W")); - putValue(Action.MNEMONIC_KEY, new Integer(KeyStroke.getKeyStroke("C").getKeyCode())); - m_view = parent; + public FileCloseAction() { + super("close-file"); + // putValue(Action.ACCELERATOR_KEY,KeyStroke.getKeyStroke("ctrl W")); }//}}} //{{{ actionPerformed() - - public void actionPerformed(ActionEvent e) { + public void invoke(TabbedView view, ActionEvent evt) { try { - jsXe.closeDocumentBuffer(m_view, m_view.getDocumentBuffer()); + jsXe.closeDocumentBuffer(view, view.getDocumentBuffer()); } catch (IOException ioe) { - JOptionPane.showMessageDialog(m_view, ioe, "I/O Error", JOptionPane.WARNING_MESSAGE); + JOptionPane.showMessageDialog(view, ioe, "I/O Error", JOptionPane.WARNING_MESSAGE); } }//}}} - - //{{{ Private members - private TabbedView m_view; - //}}} + } Modified: trunk/jsxe/src/net/sourceforge/jsxe/action/FileCloseAllAction.java =================================================================== --- trunk/jsxe/src/net/sourceforge/jsxe/action/FileCloseAllAction.java 2006-06-15 21:52:24 UTC (rev 965) +++ trunk/jsxe/src/net/sourceforge/jsxe/action/FileCloseAllAction.java 2006-06-20 19:29:38 UTC (rev 966) @@ -26,16 +26,11 @@ 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.jsXe; +import net.sourceforge.jsxe.LocalizedAction; import net.sourceforge.jsxe.DocumentBuffer; -import net.sourceforge.jsxe.gui.Messages; import net.sourceforge.jsxe.gui.TabbedView; //}}} @@ -44,9 +39,6 @@ //}}} //{{{ Swing components -import javax.swing.Action; -import javax.swing.AbstractAction; -import javax.swing.KeyStroke; import javax.swing.JOptionPane; //}}} @@ -62,28 +54,20 @@ * @author Trish Hartnett (<a href="mailto:tri...@me...">tri...@me...</a>) * @version $Id$ */ -public class FileCloseAllAction extends AbstractAction { +public class FileCloseAllAction extends LocalizedAction { //{{{ FileCloseAllAction constructor - - public FileCloseAllAction(TabbedView parent) { - //putValue(Action.NAME, "Close All"); - putValue(Action.NAME, Messages.getMessage("File.CloseAll")); - putValue(Action.MNEMONIC_KEY, new Integer(KeyStroke.getKeyStroke("E").getKeyCode())); - m_view = parent; + public FileCloseAllAction() { + super("close-all"); }//}}} - //{{{ actionPerformed() - - public void actionPerformed(ActionEvent e) { + //{{{ invoke() + public void invoke(TabbedView view, ActionEvent evt) { try { - jsXe.closeAllDocumentBuffers(m_view); + jsXe.closeAllDocumentBuffers(view); } catch (IOException ioe) { - JOptionPane.showMessageDialog(m_view, ioe, "I/O Error", JOptionPane.WARNING_MESSAGE); + JOptionPane.showMessageDialog(view, ioe, "I/O Error", JOptionPane.WARNING_MESSAGE); } }//}}} - //{{{ Private members - private TabbedView m_view; - //}}} } Modified: trunk/jsxe/src/net/sourceforge/jsxe/action/FileExitAction.java =================================================================== --- trunk/jsxe/src/net/sourceforge/jsxe/action/FileExitAction.java 2006-06-15 21:52:24 UTC (rev 965) +++ trunk/jsxe/src/net/sourceforge/jsxe/action/FileExitAction.java 2006-06-20 19:29:38 UTC (rev 966) @@ -26,24 +26,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.jsXe; -import net.sourceforge.jsxe.gui.Messages; +import net.sourceforge.jsxe.LocalizedAction; 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; //}}} @@ -56,25 +45,17 @@ * @author Trish Hartnett (<a href="mailto:tri...@me...">tri...@me...</a>) * @version $Id$ */ -public class FileExitAction extends AbstractAction { +public class FileExitAction extends LocalizedAction { //{{{ FileExitAction constructor - - public FileExitAction(TabbedView parent) { - //putValue(Action.NAME, "Exit"); - putValue(Action.NAME, Messages.getMessage("File.Exit")); - putValue(Action.ACCELERATOR_KEY,KeyStroke.getKeyStroke("ctrl Q")); - putValue(Action.MNEMONIC_KEY, new Integer(KeyStroke.getKeyStroke("X").getKeyCode())); - view = parent; + public FileExitAction() { + super("exit"); + // putValue(Action.ACCELERATOR_KEY,KeyStroke.getKeyStroke("ctrl Q")); }//}}} - //{{{ actionPerformed() - - public void actionPerformed(ActionEvent e) { + //{{{ invoke() + public void invoke(TabbedView view, ActionEvent evt) { jsXe.exit(view); }//}}} - //{{{ Private members - private TabbedView view; - //}}} } Modified: trunk/jsxe/src/net/sourceforge/jsxe/action/FileNewAction.java =================================================================== --- trunk/jsxe/src/net/sourceforge/jsxe/action/FileNewAction.java 2006-06-15 21:52:24 UTC (rev 965) +++ trunk/jsxe/src/net/sourceforge/jsxe/action/FileNewAction.java 2006-06-20 19:29:38 UTC (rev 966) @@ -26,23 +26,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.jsXe; -import net.sourceforge.jsxe.gui.Messages; +import net.sourceforge.jsxe.LocalizedAction; 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; @@ -60,21 +50,16 @@ * @author Trish Hartnett (<a href="mailto:tri...@me...">tri...@me...</a>) * @version $Id$ */ -public class FileNewAction extends AbstractAction { +public class FileNewAction extends LocalizedAction { //{{{ FileNewAction constructor - - public FileNewAction(TabbedView parent) { - //putValue(Action.NAME, "New"); - putValue(Action.NAME, Messages.getMessage("File.New")); - putValue(Action.ACCELERATOR_KEY,KeyStroke.getKeyStroke("ctrl N")); - putValue(Action.MNEMONIC_KEY, new Integer(KeyStroke.getKeyStroke("N").getKeyCode())); - view = parent; + public FileNewAction() { + super("new-file"); + // putValue(Action.ACCELERATOR_KEY,KeyStroke.getKeyStroke("ctrl N")); }//}}} - //{{{ actionPerformed() - - public void actionPerformed(ActionEvent e) { + //{{{ invoke() + public void invoke(TabbedView view, ActionEvent evt) { try { boolean success = jsXe.openXMLDocument(view, jsXe.getDefaultDocument()); if (!success) { @@ -85,7 +70,4 @@ } }//}}} - //{{{ Private members - private TabbedView view; - //}}} } Modified: trunk/jsxe/src/net/sourceforge/jsxe/action/FileOpenAction.java =================================================================== --- trunk/jsxe/src/net/sourceforge/jsxe/action/FileOpenAction.java 2006-06-15 21:52:24 UTC (rev 965) +++ trunk/jsxe/src/net/sourceforge/jsxe/action/FileOpenAction.java 2006-06-20 19:29:38 UTC (rev 966) @@ -26,23 +26,15 @@ 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.jsXe; -import net.sourceforge.jsxe.gui.Messages; +import net.sourceforge.jsxe.LocalizedAction; import net.sourceforge.jsxe.gui.TabbedView; //}}} //{{{ Swing components -import javax.swing.Action; -import javax.swing.AbstractAction; import javax.swing.JOptionPane; -import javax.swing.KeyStroke; //}}} //{{{ AWT components @@ -61,21 +53,16 @@ * @author Trish Hartnett (<a href="mailto:tri...@me...">tri...@me...</a>) * @version $Id$ */ -public class FileOpenAction extends AbstractAction { +public class FileOpenAction extends LocalizedAction { //{{{ FileOpenAction constructor - - public FileOpenAction(TabbedView parent) { - //putValue(Action.NAME, "Open..."); - putValue(Action.NAME, Messages.getMessage("File.Open")); - putValue(Action.ACCELERATOR_KEY,KeyStroke.getKeyStroke("ctrl O")); - putValue(Action.MNEMONIC_KEY, new Integer(KeyStroke.getKeyStroke("O").getKeyCode())); - view = parent; + public FileOpenAction() { + super("open-file"); + // putValue(Action.ACCELERATOR_KEY,KeyStroke.getKeyStroke("ctrl O")); }//}}} - //{{{ actionPerformed() - - public void actionPerformed(ActionEvent e) { + //{{{ invoke() + public void invoke(TabbedView view, ActionEvent evt) { try { jsXe.showOpenFileDialog(view); } catch (IOException ioe) { @@ -84,7 +71,4 @@ }//}}} - //{{{ Public members - private TabbedView view; - //}}} } Modified: trunk/jsxe/src/net/sourceforge/jsxe/action/FileReloadAction.java =================================================================== --- trunk/jsxe/src/net/sourceforge/jsxe/action/FileReloadAction.java 2006-06-15 21:52:24 UTC (rev 965) +++ trunk/jsxe/src/net/sourceforge/jsxe/action/FileReloadAction.java 2006-06-20 19:29:38 UTC (rev 966) @@ -26,16 +26,11 @@ 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.jsXe; import net.sourceforge.jsxe.DocumentBuffer; -import net.sourceforge.jsxe.gui.Messages; +import net.sourceforge.jsxe.LocalizedAction; import net.sourceforge.jsxe.gui.TabbedView; import net.sourceforge.jsxe.gui.DocumentView; //}}} @@ -45,9 +40,6 @@ //}}} //{{{ Swing components -import javax.swing.Action; -import javax.swing.AbstractAction; -import javax.swing.KeyStroke; import javax.swing.JOptionPane; //}}} @@ -63,31 +55,23 @@ * @author Trish Hartnett (<a href="mailto:tri...@me...">tri...@me...</a>) * @version $Id$ */ -public class FileReloadAction extends AbstractAction { +public class FileReloadAction extends LocalizedAction { //{{{ FileReloadAction constructor - - public FileReloadAction(TabbedView parent) { - // putValue(Action.NAME, "Reload"); - putValue(Action.NAME, Messages.getMessage("File.Reload")); - putValue(Action.MNEMONIC_KEY, new Integer(KeyStroke.getKeyStroke("R").getKeyCode())); - m_view = parent; + public FileReloadAction() { + super("reload-file"); }//}}} - //{{{ actionPerformed() - - public void actionPerformed(ActionEvent e) { + //{{{ invoke() + public void invoke(TabbedView view, ActionEvent evt) { try { - DocumentView documentView = m_view.getDocumentView(); - DocumentBuffer buffer = m_view.getDocumentBuffer(); - buffer.reload(m_view); + DocumentView documentView = view.getDocumentView(); + DocumentBuffer buffer = view.getDocumentBuffer(); + buffer.reload(view); documentView.setDocumentBuffer(buffer); //reload the buffer in the documentView } catch (IOException ioe) { - JOptionPane.showMessageDialog(m_view, ioe, "I/O Error", JOptionPane.WARNING_MESSAGE); + JOptionPane.showMessageDialog(view, ioe, "I/O Error", JOptionPane.WARNING_MESSAGE); } }//}}} - //{{{ Private members - private TabbedView m_view; - //}}} } Modified: trunk/jsxe/src/net/sourceforge/jsxe/action/FileSaveAction.java =================================================================== --- trunk/jsxe/src/net/sourceforge/jsxe/action/FileSaveAction.java 2006-06-15 21:52:24 UTC (rev 965) +++ trunk/jsxe/src/net/sourceforge/jsxe/action/FileSaveAction.java 2006-06-20 19:29:38 UTC (rev 966) @@ -26,30 +26,15 @@ 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.jsXe; import net.sourceforge.jsxe.DocumentBuffer; -import net.sourceforge.jsxe.dom.XMLDocument; -import net.sourceforge.jsxe.gui.Messages; +import net.sourceforge.jsxe.LocalizedAction; import net.sourceforge.jsxe.gui.TabbedView; //}}} -//{{{ DOM classes -import org.xml.sax.SAXException; -import org.xml.sax.SAXParseException; -import javax.xml.parsers.ParserConfigurationException; -//}}} - //{{{ Swing components -import javax.swing.Action; -import javax.swing.AbstractAction; -import javax.swing.KeyStroke; import javax.swing.JOptionPane; //}}} @@ -69,21 +54,16 @@ * @author Trish Hartnett (<a href="mailto:tri...@me...">tri...@me...</a>) * @version $Id$ */ -public class FileSaveAction extends AbstractAction { +public class FileSaveAction extends LocalizedAction { //{{{ FileSaveAction constructor - - public FileSaveAction(TabbedView parent) { - // putValue(Action.NAME, "Save"); - putValue(Action.NAME, Messages.getMessage("File.Save")); - putValue(Action.ACCELERATOR_KEY,KeyStroke.getKeyStroke("ctrl S")); - putValue(Action.MNEMONIC_KEY, new Integer(KeyStroke.getKeyStroke("S").getKeyCode())); - view = parent; + public FileSaveAction() { + super("save-file"); + // putValue(Action.ACCELERATOR_KEY,KeyStroke.getKeyStroke("ctrl S")); }//}}} - //{{{ actionPerformed() - - public void actionPerformed(ActionEvent e) { + //{{{ invoke() + public void invoke(TabbedView view, ActionEvent evt) { DocumentBuffer buffer = view.getDocumentBuffer(); try { buffer.save(view); @@ -92,7 +72,4 @@ } }//}}} - //{{{ Private members - private TabbedView view; - //}}} } Modified: trunk/jsxe/src/net/sourceforge/jsxe/action/FileSaveAsAction.java =================================================================== --- trunk/jsxe/src/net/sourceforge/jsxe/action/FileSaveAsAction.java 2006-06-15 21:52:24 UTC (rev 965) +++ trunk/jsxe/src/net/sourceforge/jsxe/action/FileSaveAsAction.java 2006-06-20 19:29:38 UTC (rev 966) @@ -33,34 +33,15 @@ 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.jsXe; -import net.sourceforge.jsxe.DocumentBuffer; -import net.sourceforge.jsxe.CustomFileFilter; -import net.sourceforge.jsxe.dom.XMLDocument; -import net.sourceforge.jsxe.gui.Messages; +import net.sourceforge.jsxe.LocalizedAction; import net.sourceforge.jsxe.gui.TabbedView; //}}} -//{{{ DOM classes -import org.xml.sax.SAXException; -import org.xml.sax.SAXParseException; -import javax.xml.parsers.ParserConfigurationException; -//}}} - //{{{ Swing components -import javax.swing.Action; -import javax.swing.AbstractAction; -import javax.swing.JFileChooser; import javax.swing.JOptionPane; -import javax.swing.KeyStroke; -import javax.swing.filechooser.FileFilter; //}}} //{{{ AWT components @@ -68,9 +49,7 @@ //}}} //{{{ Java base classes -import java.io.File; import java.io.IOException; -import java.util.Vector; //}}} //}}} @@ -81,30 +60,21 @@ * @author Trish Hartnett (<a href="mailto:tri...@me...">tri...@me...</a>) * @version $Id$ */ -public class FileSaveAsAction extends AbstractAction { +public class FileSaveAsAction extends LocalizedAction { //{{{ FileSaveAsAction constructor - - public FileSaveAsAction(TabbedView parent) { - // putValue(Action.NAME, "Save As..."); - putValue(Action.NAME, Messages.getMessage("File.SaveAs")); - putValue(Action.MNEMONIC_KEY, new Integer(KeyStroke.getKeyStroke("A").getKeyCode())); - view = parent; + public FileSaveAsAction() { + super("save-as"); }//}}} - //{{{ actionPerformed() - - public void actionPerformed(ActionEvent e) { + //{{{ invoke() + public void invoke(TabbedView view, ActionEvent evt) { try { view.getDocumentBuffer().saveAs(view); } catch (IOException ioe) { JOptionPane.showMessageDialog(view, ioe, "I/O Error", JOptionPane.WARNING_MESSAGE); } - }//}}} - //{{{ Private members - private TabbedView view; - //}}} } Modified: trunk/jsxe/src/net/sourceforge/jsxe/action/OpenRecentFileAction.java =================================================================== --- trunk/jsxe/src/net/sourceforge/jsxe/action/OpenRecentFileAction.java 2006-06-15 21:52:24 UTC (rev 965) +++ trunk/jsxe/src/net/sourceforge/jsxe/action/OpenRecentFileAction.java 2006-06-20 19:29:38 UTC (rev 966) @@ -65,7 +65,6 @@ public class OpenRecentFileAction extends AbstractAction { //{{{ OpenRecentFileAction constructor - public OpenRecentFileAction(TabbedView parent, BufferHistory.BufferHistoryEntry entry) { String path = entry.getPath(); String fileName = path.substring(path.lastIndexOf(System.getProperty("file.separator"))+1); @@ -78,7 +77,6 @@ }//}}} //{{{ actionPerformed() - public void actionPerformed(ActionEvent e) { try { File file = new File(m_entry.getPath()); Modified: trunk/jsxe/src/net/sourceforge/jsxe/action/ToolsOptionsAction.java =================================================================== --- trunk/jsxe/src/net/sourceforge/jsxe/action/ToolsOptionsAction.java 2006-06-15 21:52:24 UTC (rev 965) +++ trunk/jsxe/src/net/sourceforge/jsxe/action/ToolsOptionsAction.java 2006-06-20 19:29:38 UTC (rev 966) @@ -26,24 +26,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.GlobalOptionsDialog; -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; //}}} @@ -57,24 +46,16 @@ * @author Trish Hartnett (<a href="mailto:tri...@me...">tri...@me...</a>) * @version $Id$ */ -public class ToolsOptionsAction extends AbstractAction { +public class ToolsOptionsAction extends LocalizedAction { //{{{ ToolsOptionsAction constructor - - public ToolsOptionsAction(TabbedView parent) { - //putValue(Action.NAME, "Options..."); - putValue(Action.NAME, Messages.getMessage("Tools.Options")); - putValue(Action.MNEMONIC_KEY, new Integer(KeyStroke.getKeyStroke("G").getKeyCode())); - view = parent; + public ToolsOptionsAction() { + super("general-options"); }//}}} - //{{{ actionPerformed() - - public void actionPerformed(ActionEvent e) { + //{{{ invoke() + public void invoke(TabbedView view, ActionEvent evt) { new GlobalOptionsDialog(view); }//}}} - //{{{ Private members - private TabbedView view; - //}}} } Modified: trunk/jsxe/src/net/sourceforge/jsxe/action/ToolsPluginManagerAction.java =================================================================== --- trunk/jsxe/src/net/sourceforge/jsxe/action/ToolsPluginManagerAction.java 2006-06-15 21:52:24 UTC (rev 965) +++ trunk/jsxe/src/net/sourceforge/jsxe/action/ToolsPluginManagerAction.java 2006-06-20 19:29:38 UTC (rev 966) @@ -26,23 +26,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.gui.Messages; +import net.sourceforge.jsxe.LocalizedAction; import net.sourceforge.jsxe.gui.PluginManagerDialog; 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; @@ -57,24 +47,16 @@ * @author Trish Hartnett (<a href="mailto:tri...@me...">tri...@me...</a>) * @version $Id$ */ -public class ToolsPluginManagerAction extends AbstractAction { +public class ToolsPluginManagerAction extends LocalizedAction { //{{{ ToolsPluginManagerAction constructor - - public ToolsPluginManagerAction(TabbedView parent) { - //putValue(Action.NAME, "Plugin Manager..."); - putValue(Action.NAME, Messages.getMessage("Tools.Plugin")); - putValue(Action.MNEMONIC_KEY, new Integer(KeyStroke.getKeyStroke("P").getKeyCode())); - view = parent; + public ToolsPluginManagerAction() { + super("plugin-manager"); }//}}} - //{{{ actionPerformed() - - public void actionPerformed(ActionEvent e) { + //{{{ invoke() + public void invoke(TabbedView view, ActionEvent evt) { new PluginManagerDialog(view); }//}}} - //{{{ Private members - private TabbedView view; - //}}} } Modified: trunk/jsxe/src/net/sourceforge/jsxe/action/ValidationErrorsAction.java =================================================================== --- trunk/jsxe/src/net/sourceforge/jsxe/action/ValidationErrorsAction.java 2006-06-15 21:52:24 UTC (rev 965) +++ trunk/jsxe/src/net/sourceforge/jsxe/action/ValidationErrorsAction.java 2006-06-20 19:29:38 UTC (rev 966) @@ -3,7 +3,7 @@ :tabSize=4:indentSize=4:noTabs=true: :folding=explicit:collapseFolds=1: -Copyright (C) 2002 Ian Lewis (Ian...@me...) +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,18 +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.DocumentBuffer; -import net.sourceforge.jsxe.gui.ErrorListDialog; import net.sourceforge.jsxe.gui.Messages; +import net.sourceforge.jsxe.gui.ErrorListDialog; import net.sourceforge.jsxe.gui.TabbedView; -import net.sourceforge.jsxe.gui.ActivityLogDialog; import net.sourceforge.jsxe.util.Log; //}}} @@ -50,10 +45,7 @@ //}}} //{{{ Swing components -import javax.swing.Action; -import javax.swing.AbstractAction; import javax.swing.JOptionPane; -import javax.swing.KeyStroke; //}}} //{{{ AWT components @@ -65,29 +57,18 @@ /** * The action shows the Validation Errors Dialog * - * @author Ian Lewis + * @author Ian Lewis (<a href="mailto:Ian...@me...">Ian...@me...</a>) * @version $Id$ */ -public class ValidationErrorsAction extends AbstractAction { - - // {{{ Public members - private TabbedView view; - //}}} +public class ValidationErrorsAction extends LocalizedAction { - //{{{ ValidationErrorsAction - /** - * @param TabbedView parent view containing the JSXE editor. - * Constructor for the ActivityLogActionclass - * @since jsXe 0.3pre15 - */ - public ValidationErrorsAction(TabbedView parent) { - putValue(Action.NAME, Messages.getMessage("Tools.ValidationErrors")); - putValue(Action.MNEMONIC_KEY, new Integer(KeyStroke.getKeyStroke("V").getKeyCode())); - view = parent; + //{{{ ValidationErrorsAction + public ValidationErrorsAction() { + super("validation-errors"); }//}}} - //{{{ actionPerformed() - public void actionPerformed(ActionEvent e) { + //{{{ invoke() + public void invoke(TabbedView view, ActionEvent evt) { DocumentBuffer document = view.getDocumentView().getDocumentBuffer(); Vector errors = new Vector(); Iterator itr = document.getErrors().iterator(); Modified: trunk/jsxe/src/net/sourceforge/jsxe/gui/TabbedView.java =================================================================== --- trunk/jsxe/src/net/sourceforge/jsxe/gui/TabbedView.java 2006-06-15 21:52:24 UTC (rev 965) +++ trunk/jsxe/src/net/sourceforge/jsxe/gui/TabbedView.java 2006-06-20 19:29:38 UTC (rev 966) @@ -53,15 +53,8 @@ //}}} //{{{ AWT components -import java.awt.BorderLayout; -import java.awt.Component; -import java.awt.Dimension; -import java.awt.Rectangle; -import java.awt.event.ActionEvent; -import java.awt.event.WindowAdapter; -import java.awt.event.WindowEvent; -import java.awt.event.KeyListener; -import java.awt.event.KeyEvent; +import java.awt.*; +import java.awt.event.*; //}}} //{{{ Java base classes @@ -163,12 +156,15 @@ if (plugin != null) { DocumentView newDocView = plugin.newDocumentView(buffer); - + buffer.addDocumentBufferListener(m_docBufListener); m_documentViews.add(newDocView); Component comp = newDocView.getDocumentViewComponent(); + //Add key listeners to the DocumentView and sub components + addKeyHandler(comp); + tabbedPane.addTab(buffer.getName(), getTabIcon(buffer), comp); tabbedPane.setSelectedComponent(comp); @@ -320,7 +316,13 @@ return true; }//}}} - + + protected void processKeyEvent(KeyEvent e) { + //TODO: process shortcuts + Log.log(Log.DEBUG, this, e.toString()); + super.processKeyEvent(e); + } + //{{{ Private static members private static final String _WIDTH = "tabbedview.width"; @@ -435,20 +437,21 @@ //{{{ build and add action set ActionSet set = new ActionSet("Built-In Commands"); - set.addAction("open-file", new FileOpenAction(this)); - set.addAction("save-file", new FileSaveAction(this)); - set.addAction("save-as", new FileSaveAsAction(this)); - set.addAction("reload-file", new FileReloadAction(this)); - 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)); - set.addAction("activity-log", new ActivityLogAction(this)); - set.addAction("validation-errors", new ValidationErrorsAction(this)); - jsXe.addActionSet(set); + set.addAction(new FileNewAction()); + set.addAction(new FileOpenAction()); + set.addAction(new FileSaveAction()); + set.addAction(new FileSaveAsAction()); + set.addAction(new FileReloadAction()); + set.addAction(new FileCloseAction()); + set.addAction(new FileCloseAllAction()); + set.addAction(new FileExitAction()); + set.addAction(new DocumentOptionsAction()); + set.addAction(new ToolsOptionsAction()); + set.addAction(new ToolsPluginManagerAction()); + set.addAction(new jsxeAboutDialog()); + set.addAction(new ActivityLogAction()); + set.addAction(new ValidationErrorsAction()); + ActionManager.addActionSet(set); //}}} createDefaultMenuItems(); @@ -486,9 +489,9 @@ //{{{ Create File Menu m_fileMenu = new JMenu(Messages.getMessage("File.Menu")); m_fileMenu.setMnemonic('F'); - JMenuItem menuItem = new JMenuItem(new FileNewAction(this)); + JMenuItem menuItem = new JMenuItem(ActionManager.getAction("new-file")); m_fileMenu.add( menuItem ); - menuItem = new JMenuItem(jsXe.getAction("open-file")); + menuItem = new JMenuItem(ActionManager.getAction("open-file")); m_fileMenu.add( menuItem ); //Add recent files menu @@ -496,19 +499,19 @@ m_fi... [truncated message content] |