This is essentially how I handle selection/reselection/navigation/insertion/deletion in a standardised way for ListView, TableView & TreeView, but without the adapters & interface as it is for just 3 classes.
It is probably the quickest way to get the functionality while waiting for a change request to be discussed & actioned. On 15 August 2011 19:53, Noel Grandin <[email protected]> wrote: > Hi > > It's relatively straightforward to do this yourself. > (*) Create a TextOperator interface > (*) Create adapter classes for TextInput, TextArea and TextPane that > implement TextOperator and call the necessary methods. > (*) In your CutCopyPaste class do this: > public class CutCopyPaste { > public void configure(TextInput t1) { > configure(new TextOperatorForTextInput(t1)); > } > } > > Handily keeps the casts out of the way. > > The way to do this in the core Pivot code would probably be to introduce a > new abstract class that sits above > TextInput/TextArea/TextPane. > > I suggest you log a feature request in the bug-tracker so we don't lose track > of this idea. > > Thanks, > Noel Grandin > > Roger L. Whitcomb wrote: >> I'm implementing Cut/Copy/Paste, etc. in our UI and it is fairly awkward >> to have to check for TextInput, TextArea and TextPane on every operation >> and do the casts three times for each. So, I was wondering what >> everyone thought of a "TextOperator" interface that these three classes >> implement that consists of the relevant methods: >> >> >> >> public void cut(); >> >> public void copy(); >> >> public void paste(); >> >> public void undo(); >> >> public void redo(); >> >> public void clearSelection(); >> >> public void selectAll(); >> >> public int getSelectedLength(); // Necessary for >> determining enabling of cut/copy >> >> public String getSelectedText(); >> >> >> >> This way I could cut my work to 1/3 because I simply have to cast to >> "TextOperator" and do the operations (checking for "instanceof" also). >> >> >> >> So, what does everyone think? It would be relatively trivial to >> implement the change (add the interface file and add "implements..." >> clause to the three classes (I think, not having prototyped it yet). >> >> >> >> >> >> >> >> Roger Whitcomb >> >> Architect, Engineering >> >> Ingres Corporation >> >> [email protected] <mailto:[email protected]> >> >> >> >> PHONE +1 650.587.5596 >> >> FAX +1 650.587.5550 >> >> >> >> www.ingres.com <http://www.ingres.com/> >> >> >> >> This transmission is confidential and intended solely for the use of the >> recipient named above. It may contain confidential, proprietary, or >> legally privileged information. If you are not the intended recipient, >> you are hereby notified that any unauthorized review, use, disclosure or >> distribution is strictly prohibited. If you have received this >> transmission in error, please contact the sender by reply e-mail and >> delete the original transmission and all copies from your system. >> >> >> >> > >
