Welcome!

Artificial Intelligence Authors: Pat Romanski, Yeshim Deniz, Liz McMillan, Zakia Bouachraoui, Elizabeth White

RSS Feed Item

Text Layout Framework Follow Up PureMVC Solution

In my previous post I posed the problem of using the new Text Layout Framework in an application where you already have an Undo stack/mechanism, for example in PureMVC with the Undo utility (CommandHistoryProxy).

The challenge arises because the TLF already has an UndoManager, so the solution must hook into that. Added to that, in an application you’re likely to need to serialize your TextFlow to disk/server, which means de-serializing it, which means you’re storing your data outside of the TextFlow instance and needing to keep this store up to date as the user interacts with the TextFlow via the EditManager provided by the TLF.

I was getting hung up on my application using just a single (undoable) SetPropertyCommand and was hoping I could fit the TLF editor in with this because this command had coped well with ALL other user operations so far.

To give some background to those unfamiliar with PureMVC, my code path is typically:

  1. User interacts with something inside an editor view e.g. moves an image.
  2. View dispatches a SetPropertyEvent (contains target, prop, newValue, oldValue).
  3. EditorView Mediator picks up the event and sends a SET_PROPERTY notification.
  4. Facade hears that notification and executes the SetPropertyCommand which is undoable and so automatically finds its way to the top of the Undo stack so that the user can hit Undo from anywhere.

So that worked fine for everything from moving, scaling, picking colours and files for image or video controls, even adding and removing new things to the stage. Basically most user operations can be summarised as setting a property on a target entity. But it won’t work with the Text Layout Framework for the reasons mentioned in my previous post, you can’t just set properties, you must use the methods provided.

The solution is to add another event/command pair similar to the SetProperty combination, this one is called ApplyTextFlowOperation(Event/Command) and crucially, it uses the FlowOperation class provided by the TLF.

The command looks like this:

ActionScript:

public class ApplyTextFlowOperationCommand extends UndoableCommandBase
{
        public function ApplyTextFlowOperationCommand()
        {
                super();
                registerUndoCommand(UndoApplyTextFlowOperationCommand);
        }
               
        override public function executeCommand():void
        {
                var op:FlowOperation = getNote().getBody() as FlowOperation;
                op.doOperation();
                op.textFlow.flowComposer.updateAllContainers();
        }
}

Slot this into the PureMVC architecture the same as you would any undoable command and all works fine, you can apply TextFlow operations from.

The missing piece is when to write raw XML markup from the TextFlow to your “real” model, ready for serialization. I do this automatically by detecting changes to the TextFlow inside my model (in my case a TextElement class that represents any “text fields” the user has created on screen, which stores other properties like alpha, creation date for offline-syncing and so on).

You can listen for changes to a TextFlow via:

FlowOperationEvent - dispatched when the user typed/edits a TextFlow.
CompositionCompletionEvent - dispatched when you apply a FlowOperation, such as the ApplyFormatOperation in the example above.

Read the original blog entry...

IoT & Smart Cities Stories
We are seeing a major migration of enterprises applications to the cloud. As cloud and business use of real time applications accelerate, legacy networks are no longer able to architecturally support cloud adoption and deliver the performance and security required by highly distributed enterprises. These outdated solutions have become more costly and complicated to implement, install, manage, and maintain.SD-WAN offers unlimited capabilities for accessing the benefits of the cloud and Internet. ...
Business professionals no longer wonder if they'll migrate to the cloud; it's now a matter of when. The cloud environment has proved to be a major force in transitioning to an agile business model that enables quick decisions and fast implementation that solidify customer relationships. And when the cloud is combined with the power of cognitive computing, it drives innovation and transformation that achieves astounding competitive advantage.
SYS-CON Events announced today that Silicon India has been named “Media Sponsor” of SYS-CON's 21st International Cloud Expo, which will take place on Oct 31 – Nov 2, 2017, at the Santa Clara Convention Center in Santa Clara, CA. Published in Silicon Valley, Silicon India magazine is the premiere platform for CIOs to discuss their innovative enterprise solutions and allows IT vendors to learn about new solutions that can help grow their business.
DXWorldEXPO LLC announced today that "IoT Now" was named media sponsor of CloudEXPO | DXWorldEXPO 2018 New York, which will take place on November 11-13, 2018 in New York City, NY. IoT Now explores the evolving opportunities and challenges facing CSPs, and it passes on some lessons learned from those who have taken the first steps in next-gen IoT services.
SYS-CON Events announced today that CrowdReviews.com has been named “Media Sponsor” of SYS-CON's 22nd International Cloud Expo, which will take place on June 5–7, 2018, at the Javits Center in New York City, NY. CrowdReviews.com is a transparent online platform for determining which products and services are the best based on the opinion of the crowd. The crowd consists of Internet users that have experienced products and services first-hand and have an interest in letting other potential buye...
Founded in 2000, Chetu Inc. is a global provider of customized software development solutions and IT staff augmentation services for software technology providers. By providing clients with unparalleled niche technology expertise and industry experience, Chetu has become the premiere long-term, back-end software development partner for start-ups, SMBs, and Fortune 500 companies. Chetu is headquartered in Plantation, Florida, with thirteen offices throughout the U.S. and abroad.
SYS-CON Events announced today that DatacenterDynamics has been named “Media Sponsor” of SYS-CON's 18th International Cloud Expo, which will take place on June 7–9, 2016, at the Javits Center in New York City, NY. DatacenterDynamics is a brand of DCD Group, a global B2B media and publishing company that develops products to help senior professionals in the world's most ICT dependent organizations make risk-based infrastructure and capacity decisions.
DXWorldEXPO LLC announced today that All in Mobile, a mobile app development company from Poland, will exhibit at the 22nd International CloudEXPO | DXWorldEXPO. All In Mobile is a mobile app development company from Poland. Since 2014, they maintain passion for developing mobile applications for enterprises and startups worldwide.
Nicolas Fierro is CEO of MIMIR Blockchain Solutions. He is a programmer, technologist, and operations dev who has worked with Ethereum and blockchain since 2014. His knowledge in blockchain dates to when he performed dev ops services to the Ethereum Foundation as one the privileged few developers to work with the original core team in Switzerland.
Cloud-enabled transformation has evolved from cost saving measure to business innovation strategy -- one that combines the cloud with cognitive capabilities to drive market disruption. Learn how you can achieve the insight and agility you need to gain a competitive advantage. Industry-acclaimed CTO and cloud expert, Shankar Kalyana presents. Only the most exceptional IBMers are appointed with the rare distinction of IBM Fellow, the highest technical honor in the company. Shankar has also receive...