Managing undo operations across components

Hi,
I've been able to share an IUndoManager between various RichEditableText components using the interactionManager property of their text flows and the EditManager class. This works great for undoing and redoing -- except when a component is removed from the display list.
When a text field is re-added something odd seems to happen to its text flow generation property, which causes a mismatch when compared in the EditManager, thereby preventing the next operation to undo or redo.
Are operations being applied to the text flow simply by removing and re-adding it to the display list? Or what's affecting this count?
The failure is repeatable, and in each case the text flow's generation value is greater than the operation's endGeneration (in performUndo()) or beginGeneration (in performRedo()).
What can be done to freeze the text flow or its generation value, or is there a better way of keeping the EditManager operation validation happy?
Many thanks,
Waj
Flex 4.5.20967

Hi:
We studied your case. The operation num/count will increase when the container re-attached to the box. That's work as design. Seems you can only work around it. The following is my workaround for your special case. Hope it will be helpful:
Main application:
<?xml version="1.0" encoding="utf-8"?>
<s:Application xmlns:fx="http://ns.adobe.com/mxml/2009"
   xmlns:s="library://ns.adobe.com/flex/spark"
   xmlns:mx="library://ns.adobe.com/flex/mx" minWidth="955" minHeight="600"
   creationComplete="creationCompleteHandler(event)">
<s:layout>
<s:VerticalLayout/>
</s:layout>
<fx:Script>
<![CDATA[
import flashx.undo.UndoManager;
import mx.events.FlexEvent;
protected var _textComp:TextComp;
[Bindable]
protected var _textOnDisplayList:Boolean = false;
[Bindable]
protected var _undoManager:UndoManager = new UndoManager();
protected function creationCompleteHandler(event:FlexEvent):void
_textComp = new TextComp();
_textComp.init(_undoManager);
addText();
protected function addText():void
_textComp.handleAddon();
box.addElement(_textComp);
_textOnDisplayList = true;
protected function removeText():void
if (box.contains(_textComp))
box.removeElement(_textComp);
_textOnDisplayList = false;
]]>
</fx:Script>
<s:Label text="Type some things (using flow operations such as insert, delete, cut &amp; paste etc.), remove text from display, re-add it then try to undo or redo.{'\n'}This fails because of a mismatch in EditManager (line 923 or 1018 for undo or redo, respectively)." paddingTop="10" paddingLeft="10"/>
<s:HGroup width="100%" paddingLeft="10">
<s:Button label="Remove from display" click="removeText()" enabled="{_textOnDisplayList}"/>
<s:Button label="Add to display" click="addText()" enabled="{!_textOnDisplayList}"/>
<s:Button label="Undo" click="_undoManager.undo()"/>
<s:Button label="Redo" click="_undoManager.redo()"/>
</s:HGroup>
<s:HGroup id="box" paddingLeft="10"/>
</s:Application>
Component:
<?xml version="1.0" encoding="utf-8"?>
<s:BorderContainer xmlns:fx="http://ns.adobe.com/mxml/2009"
   xmlns:s="library://ns.adobe.com/flex/spark"
   xmlns:mx="library://ns.adobe.com/flex/mx" width="400" height="300">
<fx:Script>
<![CDATA[
import flashx.textLayout.edit.EditManager;
import flashx.textLayout.elements.TextFlow;
import flashx.textLayout.events.DamageEvent;
import flashx.textLayout.tlf_internal;
import flashx.undo.IUndoManager;
use namespace tlf_internal;
[Bindable]
/** Main text flow. */
protected var _text:TextFlow;
public function init(undoManager:IUndoManager):void
_text = new TextFlow();
_text.interactionManager = new EditManager(undoManager);
public function handleAddon():void
_text.addEventListener(DamageEvent.DAMAGE, damageHandler);
private function damageHandler(event:DamageEvent):void
_text.setGeneration(_text.generation - 1);
_text.removeEventListener(DamageEvent.DAMAGE, damageHandler);
]]>
</fx:Script>
<s:RichEditableText id="textBox" editable="true" width="100%" height="100%" textFlow="{_text}"/>
</s:BorderContainer>

Similar Messages

  • Use of Vector in undo operation ?

    Hello,
    I am developing simple paint program. And want to use undo redo operation for drawing in drawing canvas. Actually I have done it with the help of Vector. But the problem is that it is not working properly. The first drawn shape is not removing with this operation and also the problem is that When i am using CTRL+Z for undoing last drawing. It is not removing last drawn shape with first undo operation. Let me know that what is the exact problem in my coding. I am not fully java programmer. So please tell me what to do for that. I want to draw n level of drawing on drawing canvas and also want to perform n level (first drawn shape) undo actions. And also want to know how to make redo button for same coding only use of Vector or ArrayList.
    My code is here:
    import java.awt.*;
    import java.awt.event.*;
    import java.awt.image.BufferedImage;
    import javax.swing.*;
    import java.util.*;
    public class PaintUndo extends JFrame
         Display pan = new Display();
    public PaintUndo()
         addWindowListener(new WindowAdapter()
        {     public void windowClosing(WindowEvent ev)
              {     dispose();
                   System.exit(0);}});
         getContentPane().add("Center",pan);
           setBounds(1,1,600,400);
         JMenuBar  menu = new JMenuBar();;
         JMenu     submenu;
         JMenuItem item, redo;
         submenu = new JMenu("Edit");     
         item = new JMenuItem("UnDo");
        item.setMnemonic(KeyEvent.VK_Z);
            item.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_Z, ActionEvent.CTRL_MASK));
         item.addActionListener((ActionListener)pan);
         submenu.add(item);   
         menu.add(submenu);
         getContentPane().add("North",menu);
         setVisible(true);
    public class Display extends JComponent implements MouseMotionListener, MouseListener, ActionListener
         Vector   saves = new Vector();
         BufferedImage image = null;
         Graphics ig;
         Graphics pg;
         Point point;
        int x1=0;
        int y1=0;
    public Display()
         setBackground(Color.pink);
         addMouseMotionListener(this);
        addMouseListener(this);
    public void paintComponent(Graphics g)
         if (image == null)
              image = (BufferedImage) createImage(800,600);
              ig = image.createGraphics();
              ig.setColor(Color.white);
              ig.fillRect(0,0,800,600);
              ig.setColor(Color.blue);
              pg = getGraphics();
              pg.setColor(Color.blue);
         g.drawImage(image,0,0,this);
    public void mouseDragged(MouseEvent e)
            int x2 = e.getX(); int y2 = e.getY();
                Graphics gr = image.getGraphics();
                   gr.drawLine(x1, y1, x2, y2);
                repaint();
                x1 = x2; y1 = y2;
    public void mouseMoved(MouseEvent e)
    public void actionPerformed(ActionEvent a)
         if (a.getActionCommand().equals("UnDo") && saves.size() > 0)
              ig.drawImage((Image)saves.remove(saves.size()-1),0,0,null);
              repaint();
            public void mouseClicked(MouseEvent e) {
                System.out.println("mouse clicked....");
            public void mousePressed(MouseEvent e) {
                System.out.println("mouse pressed....");
                x1 = e.getX();
                   y1 = e.getY();
            public void mouseReleased(MouseEvent e) {
                System.out.println("mouse released....");
               Image tmg = createImage(800,600);
              Graphics tg = tmg.getGraphics();
              tg.drawImage(image,0,0,null);
              saves.add(tmg);
            public void mouseEntered(MouseEvent e) {
            public void mouseExited(MouseEvent e) {
    public static void main (String[] args)
         new PaintUndo();
    }This is complete code for undoing.
    Any help will be appreciated.
    Thanks in advance.
    Manveer

    The example code is set up for a protocol completely different than what you are doing, so you can't simply copy it and hope it works.  The example code expects that the other side will send a 4-byte header containing the number of data bytes that follow, then send the data.  The example code first reads that 4-byte header, casts it to an integer, and reads that number of bytes (the second Bluetooth Read).
    When you run this with your device, the first read gets your 4 bytes - FF FF 22 33 - and converts that to an integer.  0xFFFF2233 is decimal 4294910515.  So you then try to read this huge number of bytes and you get an error - looks like error 1, an input parameter is invalid, because you can't read 4GB at once.  You can probably get your code working with a single Bluetooth Read, with a 1 second timeout (because you have a 1 second delay between packets).  You'll want to wire in some number of bytes to read that is at least the size of the largest packet you ever expect, but don't use a ridiculously huge number that generates an error.  LabVIEW will return as many bytes as are available when the timeout expires, even if it isn't as many as you asked to read (you might also get a timeout error, though, which you'll need to clear).  You can then do whatever you need to do with that data - search for FF FF, typecast anything after that to array of U16, display it. 
    The output of the Bluetooth Read is a string, but it's not text - it's exactly the bytes that were sent.  The Y with the dots over it is the way ASCII 255 (0xFF) displays (at least in that font).  ASCII 34 (0x22) is ", and ASCII 51 (0x33) is the number 3.

  • Undo operation on iPad..

    Has anyone noticed that the Undo operation on iPad is same as iPhone, which means you have to shake the device to undo? Shaking an iPhone is fine but very awkward for iPad give the size of the device. Needless to say, Shake to Undo is not intuitive for the first time user, even on iPhone. Very bizarre UI from Apple. I hope Apple will address this issue in the future release.

    There is a little-known gestural capability built into the keyboard on the iPad. If you simply touch and hold the "123" button, the number keyboard will come up immediately and you can just slide your finger to "Undo". When you lift your finger, the keyboard immediately returns to the alphabetic version. This sounds complicated, but it's not at all...and it's one quick, fluid motion. Like this:
    Touch "123", slide to "Undo", lift. There's no waiting for anything. Try it.

  • How to manage the operations on service order ?

    Hello,
    Do you know some bapi or MF to manage the operation on service order  (IW32).
    I have to create some operation, and in dialogue mode Iu2019m using 
    "Task list selection,  to reference object."
    But I need to do it by a bapi or MF.
    Tks a lot.
    R.

    Hi,
    Check with the following FM:
      MAINTENANCE_ITEM_POST
    Regards,
    Venkat.

  • System Managed Undo.

    Can I use the system managed undo segment (rollback segment) while refreshing of materialized view. I would try something like following
    SQL> Alter materialized view mview refresh using master rollback segment _SYSSMU9$;
    Currenty the database is running with auto undo management mode.
    Case1: No errors
    SQL> alter materialized view mview refresh using master rollback segment system;
    Materialized view altered.
    Case2: Error
    SQL> alter materialized view mview refresh using master rollback segment _SYSSMU9$;
    ERROR at line 1:
    ORA-00911: invalid character
    Why is this happening?

    I got it
    SQL> alter materialized view mview refresh using master rollback segment "_SYSSMU9$";
    works for me.

  • Cookie manager for opera mac?

    Hello: is there a cookie manager for Opera 9.1 mac? The built-in one does not measure up to mozilla's cookie managers. Thanks.

    Hey look at this:
    http://supportforums.blackberry.com/rim/board/message?board.id=blackberryformac&thread.id=2499&jump=...
    1. If any post helps you please click the below the post(s) that helped you.
    2. Please resolve your thread by marking the post "Solution?" which solved it for you!
    3. Install free BlackBerry Protect today for backups of contacts and data.
    4. Guide to Unlocking your BlackBerry & Unlock Codes
    Join our BBM Channels (Beta)
    BlackBerry Support Forums Channel
    PIN: C0001B7B4   Display/Scan Bar Code
    Knowledge Base Updates
    PIN: C0005A9AA   Display/Scan Bar Code

  • Managing root passwords across hundreds of systems

    All:
    Is there a mechanism to manage root passwords across hundreds of Solaris 10 systems? The policy requirement would be UNIQUE ROOT PASSWORDS...
    Thanks
    Sekhar Nagasundaram

    Hi,
    Your friend ssh is the answer here :)
    We do exactly this in the office, changing passwords remotely. Obviously, you will need to have some backend database to hold/generate the passwords for each machine. Once you have that, it is a matter of iterating over each machine in turn and changing the account password.
    There are three ways I can think of doing this in an automated way:
    1) on each system use sed or similar to directly alter the /etc/shadow file. (risky...)
    2) on each system use a tool, to change the /etc/shadow password file, which is passed the passwords on the command line. There is a chpass or similar tool such as this distributed with a Squirrelmail plugin for instance
    3) use an expect script to alter the password by interacting with passwd.
    Which way you implement will be largely goverened by your local policies and procedures.

  • Userexit required to update operation of components in production orders

    Hello,
    Is there a userexit or badi that exists to change operations of components in a production order?
    As soon as a production order is created or modified, we need to have the system automatically adjust the operation of each component according to the value of a specific field in the material master. In certain cases, the operation must be 0010. In other cases, the operation must be 0030. Our PP master data is setup to have all materials assigned to a dummy workcenter (operation 0010).
    Enhancement PPCO0023 doesn't work because the user exit only gets executed if the user manually goes into the components screen and makes a change to a component.
    Thanks for your help,
    Marie-Eve

    Hi MARIE,
    There is no user exit as such.
    Regards,
    Satyajit

  • How can we manage the operations subcontracted in B1 ?

    Good morning
    How can we manage the operations subcontracted in B1?
    For example.
    I have a purchased item (a box A0001)
    I must paint (Service Item  P0001)
    I have a finished product that I sell (The box painted A0002)
    I have a BOM  for this item  which contains
    A0001 + P00001
    Can we have a floating price for article P0001?
    Can we have a purchase order for the Item P0001 from a production order of item A0002 ?
    etc. ...
    I am a new French partner. My apologies if this issue already exists and then for my English .....

    Can we have a floating price for article P0001?
    P0001 being a service item would be defined as a standard cost item with Issue method backflush.  In this case using a floating price might not be possible. 
    You could actually consider the quantity to be the price and define the price as 0.1 / any lowest mutiple and in the Production Order change the quantity to equal the total cost of painting.
    Can we have a purchase order for the Item P0001 from a production order of item A0002 ?
    P0001 if defined as a labor / service item cannot be purchased.

  • Redo and undo operations in lingo.

    I wanted to know how you people develop redo and undo method in a director project using lingo? Is there any standard function which keeps track of user interactions and provide the traditional method of redo and undo? Else should i develop a own logic? I'm new to lingo programming, so asking you experienced people how to go about it?

    Thanks, finally i was able to create undo operation in lingo! Lists are very helpfull in lingo, i got to know these just after coding undo action, i was able to create with counters and two lists.
    Here is just sample i did, not too great though!
    global clicklist, counter, undolist, undocounter
    on mouseUp me
    -- store values in variables for undo operation
      spriteName = undolist.getAt(undocounter - 2)
      spriteX = undolist.getAt(undocounter - 1)
      spriteY = undolist.getlast(undocounter) 
      sprite(spriteName).loc = point(spriteX, spriteY)
      undolist.deleteAt(undocounter)
      undolist.deleteAt(undocounter-1)
      undolist.deleteAt(undocounter-2)
      undocounter = undocounter - 3
    end

  • Config Manager and Operations Manager on same server

    May be a simple question, but I have Systems Center Configuration Manager 2012 R2 setup on my Windows Server 2012 R2.  I have the SQL 2012 database running on the same server.  I'd like to install Operations Manager console/database on the same
    server.  Can these co-exist on the same machine/database?  I found the article from Microsoft (http://technet.microsoft.com/en-us/library/dn281928.aspx) that explicitly says:
    DPM Management Server
    Operations Manager Management Server
    Service Manager Management Server
    Service Manager Data Warehouse Management Server
    cannot co-exist on the same server, but it does not mention Configuration manager so I'm assuming its OK?  Does anyone know for sure?

    Hi,
    Sccm requires a separate sql instance, Cameron covers the topic here:http://blogs.catapultsystems.com/cfuller/archive/2012/05/23/system-center-2012%E2%80%93using-a-common-sql-backend-database-sysctr-scom-scsm.aspx
    From a performance and complexity perspective I would strongly advice you to avoid it.
    /Jörgen
    -- My System Center blog ccmexec.com -- Twitter
    @ccmexec

  • My iPad 2 is blocked. I cannot switch it off or manage whatever operation

    Good morning.
    My iPad2 is blocked (screen) on a photo. I cannot close it with fingers, or switch it off by acting on buttons, or manage whatever operation. The battery is charged.

    iPad: Basic troubleshooting
    iPad: Troubleshooting touchscreen response

  • Accessing Items Across Components

    Hello All,
    I'm having trouble figuring out how to access items (in this
    case an accordion) across components.
    In my application I have a main.mxml file which contains a
    viewstack that uses homeview.mxml and buyersview.mxml to display
    different content.
    buyersview.mxml contains an accordion that I'd like to be
    able to access from homeview.mxml. I tried using
    click="this.parentApplication.buyersview.buyersAccordion.selectedIndex=1".
    This does not return an error but it doesn't work either.
    Any help would be appreciated

    You are or will be hitting the deferred instantiation issue.
    Non-visible children of ViewStack or Accordion, are not created
    until the user navigates to that view.
    It is bad practice to attempt to set component properties
    from the outside, and this is one reason. Instead, use the
    creationComplete and/or show events to "pull" the data you want
    into the component.
    Your theory is good on the inter-component communication. You
    may need to approach it one step at a time to verify your
    expression. Application.application resolves to the top-level
    application scope. I tend to use that more than parentDocument.
    Tracy

  • Hello, I have a big problem with Firefox: Session Manager & Undo Closed Tab addons are not working, Sync Is not working. History is working. How to fix this?

    Firefox remembers history but doesn't remember closed tabs, sessions.
    It happened after updating Fox to v. 19.0.2 on one computer.
    In Firefox Options is set Use Custom Settings For History, everything is checked except Always Use Private Browsing Mode. So I am not in private browsing.
    When I press on Undo Closed Button nothing happens & in session manager Save Session Button is greyed out. I've tried installing other add-ons that can remember tabs. tried to disable/reinstall these 2 add-ons. Did't help. On my 2nd computer I have same add-ons, same settings and they are working normally. on 3rd computer undo closed tabs works also. How to fix this? I decided to ask before doing Firefox Reset...
    Sync is a separate problem. It works, but quite often it logs me out of Sync account. Then I can log in only using long recovery key and password (choosing option I don't have device with me because it does not accept keys for pairing device.)
    Thanks for reading.

    I have exactly the same settings in Options (in both computers)
    for history, these 2 add-ons and all other stuff in Options. The only difference is that on 1 pc sessions can be saved and closed tabs can be reopened, on other main pc they stopped to work. + no any other add-on that does similar things works on this pc.
    It is also interesting that I can reopen closed visited sites from History Panel, but not by pressing the Button. For now I only manually bookmark links to a temporary folder.
    Recently (some 2 month ago) I pressed x and Firefox closed all tabs without saving them without displaying save & quit pop up.
    so I changed 4 settings in about.config
    browser.tabs.warn on close true
    browser.warn on quit true
    browser.warn on restart true
    browser.show.quit warning true
    but the problem with sessions appeared only 1 week ago.
    So I guess the problem is not with the History settings or other settings. Seems that something responsible for button or for storing info about tabs/sessions got corrupted. :(

  • Someone PLEASE Check The Media Manager Program! RunTime Components Will NOT Download Properly!

    I am a Verizon FiOS subscriber, and my family members have Verizon apps and programs on their computers.  For some ungodly reason, Media Manager does NOT install properly once the initial download program is acquired.  There is a message that comes up that says "Media Manger installer is having a problem accessing the server to download RunTime components. Please try again later."  I've had my brother call because he is the most technically inclined, and despite being on the phone extensively with Verizon representatives, NO-ONE has fixed or seems to be able to fix this problem!
    I would appreciate it if someone would please either fix the files at the server, fix the downloader so that it goes to whatever new area where the runtime components are, or post the correct link to perhaps a full installer of Verizon MediaManager.  It is very frustrating that despite calling, I have not gotten ANY proper assistance with this issue!
    Sincerely,
    LorraineBMoses
    {edited for privacy}

    What OS are you running?
    If Vista or Windows 7, Try right clicking the install program and selecting run as administrator. See if that helps.

Maybe you are looking for

  • Ugliness in App Store

    I'm posting this hoping someone at the developing team will please have a look at their own creations. In App Store under Top 25 the button in upper left corner has a text line (Top Paid iPhone Apps) that is longer than the size of the button. That s

  • Text find and Highlight

    I have a textbox that I am loading text from instructionsArray that gets data from a XML file.  I want to search that textbox for a word that might be in the dictionaryArray that gets data from and XML file. Then I want the word if its there to be hi

  • Processing Several Records in a CSV File

    Hello Experts! I'm currently using XI to process an incoming CSV file containing Accounts Payable information.  The data from the CSV file is used to call a BAPI in the ECC (BAPI_ACC_DOCUMENT_POST).  Return messages are written to text file.  I'm als

  • Oracle Access Manager API (ASDK) - ObUserSession / ObConfig Issues

    I am currently working with the ASDK and CoreID 7.0.4. I have gotten my custom Access Gate to the point where I wanted to start testing it out with my applications. I very quickly ran into some issues: Im my code I am making a connection to the Acces

  • Video Cameras  What should I buy Panasonic or Sony?

    I am looking to upgrade to a new camcorder from a Panasonic TM700 to either a Panasonic HC-X900M or a Sony HDRPJ760VE. The reason for the upgrade is because my TM700 will no longer switch off, making it necessary for me to detach the battery after ea