/** * Begins recording a macro. After this method is called, all input/caret * events, etc. are recorded until <code>endMacroRecording</code> is * called. If this method is called but the text component is already * recording a macro, nothing happens (but the macro keeps recording). * * @see #isRecordingMacro() * @see #endRecordingMacro() */ public static synchronized void beginRecordingMacro() { if (isRecordingMacro()) { //System.err.println("Macro already being recorded!"); return; } //JOptionPane.showMessageDialog(this, "Now recording a macro"); if (currentMacro!=null) { currentMacro = null; // May help gc? } currentMacro = new Macro(); recordingMacro = true; }
/** * Adds an action event to the current macro. This shouldn't be called * directly, as it is called by the actions themselves. * * @param id The ID of the recordable text action. * @param actionCommand The "command" of the action event passed to it. */ static synchronized void addToCurrentMacro(String id, String actionCommand) { currentMacro.addMacroRecord(new Macro.MacroRecord(id, actionCommand)); }
/** * "Plays back" the last recorded macro in this text area. */ public synchronized void playbackLastMacro() { if (currentMacro!=null) { List<MacroRecord> macroRecords = currentMacro.getMacroRecords(); if (!macroRecords.isEmpty()) { Action[] actions = getActions(); undoManager.beginInternalAtomicEdit(); try { for (MacroRecord record : macroRecords) { for (int i=0; i<actions.length; i++) { if ((actions[i] instanceof RecordableTextAction) && record.id.equals( ((RecordableTextAction)actions[i]).getMacroID())) { actions[i].actionPerformed( new ActionEvent(this, ActionEvent.ACTION_PERFORMED, record.actionCommand)); break; } } } } finally { undoManager.endInternalAtomicEdit(); } } } }
boolean parsedOK = initializeFromXMLFile(doc.getDocumentElement()); if (!parsedOK) { name = null;
/** * Saves this macro to an XML file. This file can later be read in by the * constructor taking a <code>File</code> parameter; this is the mechanism * for saving macros. * * @param file The file in which to save the macro. * @throws IOException If an error occurs while generating the XML for * the output file. * @see #saveToFile(String) */ public void saveToFile(File file) throws IOException { saveToFile(file.getAbsolutePath()); }
boolean parsedOK = initializeFromXMLFile(doc.getDocumentElement()); if (!parsedOK) { name = null;
/** * Saves this macro to an XML file. This file can later be read in by the * constructor taking a <code>File</code> parameter; this is the mechanism * for saving macros. * * @param file The file in which to save the macro. * @throws IOException If an error occurs while generating the XML for * the output file. * @see #saveToFile(String) */ public void saveToFile(File file) throws IOException { saveToFile(file.getAbsolutePath()); }
/** * Adds an action event to the current macro. This shouldn't be called * directly, as it is called by the actions themselves. * * @param id The ID of the recordable text action. * @param actionCommand The "command" of the action event passed to it. */ static synchronized void addToCurrentMacro(String id, String actionCommand) { currentMacro.addMacroRecord(new Macro.MacroRecord(id, actionCommand)); }
/** * Begins recording a macro. After this method is called, all input/caret * events, etc. are recorded until <code>endMacroRecording</code> is * called. If this method is called but the text component is already * recording a macro, nothing happens (but the macro keeps recording). * * @see #isRecordingMacro() * @see #endRecordingMacro() */ public static synchronized void beginRecordingMacro() { if (isRecordingMacro()) { //System.err.println("Macro already being recorded!"); return; } //JOptionPane.showMessageDialog(this, "Now recording a macro"); if (currentMacro!=null) currentMacro = null; // May help gc? currentMacro = new Macro(); recordingMacro = true; }
Action[] actions = getActions(); int numActions = actions.length; List macroRecords = currentMacro.getMacroRecords(); int num = macroRecords.size(); if (num>0) {
boolean parsedOK = initializeFromXMLFile(doc.getDocumentElement()); if (parsedOK==false) { name = null;
/** * Adds an action event to the current macro. This shouldn't be called * directly, as it is called by the actions themselves. * * @param id The ID of the recordable text action. * @param actionCommand The "command" of the action event passed to it. */ static synchronized void addToCurrentMacro(String id, String actionCommand) { currentMacro.addMacroRecord(new Macro.MacroRecord(id, actionCommand)); }
/** * Begins recording a macro. After this method is called, all input/caret * events, etc. are recorded until <code>endMacroRecording</code> is * called. If this method is called but the text component is already * recording a macro, nothing happens (but the macro keeps recording). * * @see #isRecordingMacro() * @see #endRecordingMacro() */ public static synchronized void beginRecordingMacro() { if (isRecordingMacro()) { //System.err.println("Macro already being recorded!"); return; } //JOptionPane.showMessageDialog(this, "Now recording a macro"); if (currentMacro!=null) { currentMacro = null; // May help gc? } currentMacro = new Macro(); recordingMacro = true; }
/** * "Plays back" the last recorded macro in this text area. */ public synchronized void playbackLastMacro() { if (currentMacro!=null) { List<MacroRecord> macroRecords = currentMacro.getMacroRecords(); if (!macroRecords.isEmpty()) { Action[] actions = getActions(); undoManager.beginInternalAtomicEdit(); try { for (MacroRecord record : macroRecords) { for (int i=0; i<actions.length; i++) { if ((actions[i] instanceof RecordableTextAction) && record.id.equals( ((RecordableTextAction)actions[i]).getMacroID())) { actions[i].actionPerformed( new ActionEvent(this, ActionEvent.ACTION_PERFORMED, record.actionCommand)); break; } } } } finally { undoManager.endInternalAtomicEdit(); } } } }
boolean parsedOK = initializeFromXMLFile(doc.getDocumentElement()); if (parsedOK==false) { name = null;
/** * Adds an action event to the current macro. This shouldn't be called * directly, as it is called by the actions themselves. * * @param id The ID of the recordable text action. * @param actionCommand The "command" of the action event passed to it. */ static synchronized void addToCurrentMacro(String id, String actionCommand) { currentMacro.addMacroRecord(new Macro.MacroRecord(id, actionCommand)); }
/** * Begins recording a macro. After this method is called, all input/caret * events, etc. are recorded until <code>endMacroRecording</code> is * called. If this method is called but the text component is already * recording a macro, nothing happens (but the macro keeps recording). * * @see #isRecordingMacro() * @see #endRecordingMacro() */ public static synchronized void beginRecordingMacro() { if (isRecordingMacro()) { //System.err.println("Macro already being recorded!"); return; } //JOptionPane.showMessageDialog(this, "Now recording a macro"); if (currentMacro!=null) currentMacro = null; // May help gc? currentMacro = new Macro(); recordingMacro = true; }
Action[] actions = getActions(); int numActions = actions.length; List macroRecords = currentMacro.getMacroRecords(); int num = macroRecords.size(); if (num>0) {