Custom CompaundEdit  for improved Undo Support

Hi,
how can i create a custom CompoundEdit for my JTextPane? By default every change on my Document is one Edit, so that everytime i press a Key, an Edit is created and put into my UndoManager, but i want to undo more than one character once i pressed my Undo Button, like MSWord does.
I really dont know where to start?
It would be great if someone can help me.
kbj

I think the original request is for the ability to undo multple groups of edits. For example:
1) enter 'abc'
2) go back to start of document and enter '123'
3) undo should remove '123'
4) undo again should remove 'abc'
(the default undo would remove 3, 2, 1, c, b, a)
Stas, the solution you provided removes '123abc' when the first undo is invoked.
Assuming, my understanding of the question is what the user wants, the following code works. My approach is to build a compound edit with individual edits that differ from the previous offset by only 1. When the offset is greater than 1, the compound edit is 'ended' and added to the UndoManager.
The problem with this approach is that the compound edit is always considered 'inProgress' and the canUndo() method always returns false. Using suggestions found in this thread I then attempted to create MyCompoundEdit and override the addEdit() method so I could end() the compound edit as soon as it is created. Now, the canUndo() method works however, all edits are merged into 1 when an undo is done.
Maybe, my approach will give some ideas to others who might be able to solve the problem.
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import javax.swing.text.*;
import javax.swing.event.*;
import javax.swing.undo.*;
public class CompoundUndoManager extends UndoManager implements     UndoableEditListener
     public CompoundEdit compoundEdit;
     private JTextComponent editor;
     private int lastOffset;
     public CompoundUndoManager(JTextComponent editor)
          this.editor = editor;
          editor.getDocument().addUndoableEditListener( this );
     public void undoableEditHappened(UndoableEditEvent e)
          // Start a new compound edit
          if (compoundEdit == null)
               compoundEdit = startCompoundEdit( e.getEdit() );
               return;
          //  Check for an incremental edit
          if (editor.getCaretPosition() == lastOffset + 1)
               compoundEdit.addEdit( e.getEdit() );
               lastOffset++;
               return;
          //  Not incremental edit, start a new one
          compoundEdit.end();
          compoundEdit = startCompoundEdit( e.getEdit() );
     private CompoundEdit startCompoundEdit(UndoableEdit anEdit)
          lastOffset = editor.getCaretPosition();
          compoundEdit = new CompoundEdit();
          // Uncomment the following two lines to use MyCompoundEdit
          // unfortunately all edits are merged back into one
//          compoundEdit = new MyCompoundEdit();
//          compoundEdit.end();
          compoundEdit.addEdit( anEdit );
          addEdit( compoundEdit );
          return compoundEdit;
     class MyCompoundEdit extends CompoundEdit
          public boolean addEdit(UndoableEdit anEdit)
               edits.addElement(anEdit);
               return true;
     public static void main(String[] args)
          final JTextPane textPane = new JTextPane();
          textPane.setPreferredSize( new Dimension(200, 200) );
          final CompoundUndoManager undoManager = new CompoundUndoManager( textPane );
          JPanel panel = new JPanel();
          panel.setLayout( new BorderLayout() );
          panel.add( textPane, BorderLayout.CENTER );
          JPanel buttons = new JPanel();
          panel.add(buttons, BorderLayout.SOUTH);
          JButton undo = new JButton( "Undo" );
          undo.addActionListener( new ActionListener()
               public void actionPerformed(ActionEvent e)
                    try
                         System.out.println( undoManager.canUndo() );
                         undoManager.compoundEdit.end();
                         System.out.println( undoManager.canUndo() );
                         undoManager.undo();
                         textPane.requestFocus();
                    catch (CannotUndoException ex)
                         System.out.println("Unable to undo: " + ex);
          buttons.add( undo );
          JButton redo = new JButton( "Redo" );
          redo.addActionListener( new ActionListener()
               public void actionPerformed(ActionEvent e)
                    try
                         undoManager.redo();
                         textPane.requestFocus();
                    catch (CannotRedoException ex)
                         System.out.println("Unable to redo: " + ex);
          buttons.add( redo );
          JFrame frame = new JFrame("Compound Edit");
          frame.setDefaultCloseOperation( JFrame.EXIT_ON_CLOSE );
          frame.getContentPane().add( panel );
          frame.pack();
          frame.setVisible(true);
}

Similar Messages

  • MSI GT660 need a custom bios for SSD drive support

    HEllo,
    I am looking for a custom bios that has SSD support for my MSI GT660 003us note book.
    Thanks

    hello, what issue you have with the ssd?

  • What does "improved international support " mean for new Airport software?

    what does "improved international support " mean for new Airport software?

    Improved language support, presumably, or more WiFi channels in some areas.

  • Customer feedback to Adobe for improvements to PSE

    What mechanisms exist for customers to provide feedback to Adobe regarding suggestions and requests for improvements to Photoshop Elements?  While I have been satisfied with the changes that have been made from PSE4 through PSE8, there are a number of changes I'd like to see in the next version to make it better suited to my needs - mostly in the Organizer, in regard to tags and captions.

    Thanks for providing the link.  However, the page that is loaded into Internet Explorer 8 (running on a 64-bit Windows 7 laptop) locks up and refuses to even scroll. I have also noticed this phenomen when attempting to use the PSE 7 or 8 Help facility. While I accept the fact that PSE 7 & 8  weren't designed for this system, I don't understand how any webpage can lock up IE8.
    Should I submit my suggestions for improvements to PSE8 on this Forum?

  • How do I leverage a custom theme for Outlook 2013?

    Microsoft has a problem. They use the term "theme" in Office in 2 different ways: 1) the 3 background colors you can choose of the Office applications and 2) a collection of colors, fonts, and layout that can be customized and defined by the user
    for the applications.
    I know how to create a theme in PowerPoint and save it as a default for all new presentations. Allegedly you can you this across Office applications but this is where it breaks down (as far as my user experience goes).
    I've created a theme in PowerPoint. It has my custom colors. I want to use that same collection in Outlook.
    I can apply it on a email by email basis (Options menu for an email), but I want the default email (new or reply) to use that custom theme. I see my theme in the drop down menu under a heading of Custom, but there isn't a way to set it as default
    (behavior differs from PowerPoint here).
    So I look under the Outlook File menu, then Options and select Mail. You can change stationary, but the custom theme isn't an option there.
    Then there is Styles under the Format Text menu when in a new email. There are color options and font options, but again, no way to leverage the work I did in creating the custom theme.
    Searching on customizing themes for Outlook only gets me answers on the first use of the word theme, not the latter.
    Is there no way to you the theme I created for Outlook 2013?

    Its very simple - if you want a product that remains consistent and does not change its layout every few years, that is fully customizable, and will remain being supported by subsequent operating systems, then get an open source product running in an open
    source OS. It seems that you can no longer rely on MS to provide consistency, stability, or support for their own products. 
    When will MS realise that customer familiarity with their products is their intellectual property, like branding, which you would never trash every five years. Imagine that MS wanted to change their name to a new company name, or their Outlook brand to Inlook
    - it would never happen. So why is thee trade getup and arrangement changing so often and against what their customers want? Is it to justify thee new products? Maybe with cloud and 365, they will finally be happy and stop mucking about with what works (after
    they change everything back to '95 /XP format?).

  • Custom pagination for APEX 4.2 interactive report using Page Zero

    Hi,
    I want to implement an «Custom pagination for APEX 4.2 interactive report» using a «page zero».
    I recently migrate from Apex 3.1 to Apex 4.2 and my «Custom pagination for APEX 3.1 interactive report» using a «page zero»  is not working any more.
    So now I try to adapt an excellent example of Jari Laine for 4.0 but using a page zero.
    I put the code JavaScript to Page zero but I must create an dynamic action to fire only for an interactive report region.
    It’s a good idea?
    Thank you

    Thought I would try once more with my DatePicker question.
    On the Apex.Oracle.Com website I have created a 1 page application that has an Interactive Report.
    [url http://apex.oracle.com/pls/apex/f?p=15655:1]
    user = 'test'
    password = 'test'
    I have 2 questions :
    (1) In IE7, press 'Actions', 'Filter'. On the Column dropdown list, select 'Order Timestamp'.
    Notice the prompt icon to the right of the 'expression'. This should change to the Datepicker, but in IE7 it does not. Try the samething in Firefox or Chrome and the Datepicker will appear.
    Is this a BUG, or does Apex 4.02 not support IE7 ?
    (2) In Firefox or Chrome, where you can now see the Datepicker, you will notice that it is the new style picker, not the old style ( called 'classic' ). I want to change it so that it shows the 'classic' datepicker not the new, but cannot see how to do it, if indeed you actually can.
    I would really appreciate it if someone could take a look and let me know if I am going mad, or if we need to get all our users onto IE8. We have now gone live with Apex 4.02 and need to resolve these issues.
    Thanks in advance.
    Edited by: DooRon on 10-Mar-2011 05:13

  • Outlook 2013 with Exchange Server - Changed custom form for contacts is not shown

    Hello,
    Our infrastructure:
    Exchange Server 2010
    Outlook 2010
    Outlook 2013
    Windows 7 Pro, Windows 8 Pro and Windows 8.1 Pro
    The situation:
    We've used an old custom form for contacts, worked perfectly fine
    I've updated the form (adding some new custom fields and checkboxes) using Outlook 2013 and publishing the form (with a new name) to the Exchange folder
    I've set the form as default form in our contacts folder
    I've used this Script to set the new form for the existing contacts  and the name of the new form is saved correctly
    BUT if I open a contact in our Exchange contacts folder, Outlook 2013 (Outlook 2010) still shows the old form
    Steps I've taken so far:
    Cleared Outlook forms cache
    Repeated the above steps 1-4 in Outlook 2010
    Switched Cached Exchange Mode off and back on
    Allowed Scripts in Trust Center Settings
    Used a new clean Windows installation with a new Outlook 2013 installation
    Used different Exchange users on different systems, but some behavior when opening contacts
    I'm out of options I can think of, so maybe somebody else has some new view on this problem. 
    Thank you very much in advance!
    Greetings,
    Karl

    Hi,
    Is the Exchange folder in which the custom form is published available to all users?
    From the description, the script used to work for the old custom form, correct? Which version of Outlook did you use with the old custom contact form? Outlook 2010/Outlook 2013 or an earlier version? If you used the script with an earlier version of Outlook,
    we can't make sure it will still work with Outlook 2010/Outlook 2013.
    In addition we may also try creating a new contact form and test the steps to see if it will work.
    Please let me know the result.
    Regards,
    Steve Fan
    TechNet Community Support
    It's recommended to download and install
    Configuration Analyzer Tool (OffCAT), which is developed by Microsoft Support teams. Once the tool is installed, you can run it at any time to scan for hundreds of known issues in Office
    programs.
    Please remember to mark the replies as answers if they help, and unmark the answers if they provide no help. If you have feedback for TechNet Support, contact
    [email protected]

  • Is it possible to override the built-in PDF format handler with a custom IFilter for PDF?

    Hi,
    SharePoint 2013 comes with a built-in "format handler" for PDF now, so it can index PDF files out of the box. This is great for most users, as it now no longer is necessary to install a third-party IFilter for crawling PDF documents.
    My question is, is it possible to override the built-in format handler for PDF with a custom IFilter for PDF? I played with the Set-SPEnterpriseSearchFileFormatState and Remove-SPEnterpriseSearchFileFormat cmdlets. While it is possible to deactivate
    the built-in format handler, I was not able to remove it and to create a new one that activates a custom IFilter for PDF files.
    Background of the question: While the new built-in format handler for PDF will probably be sufficient for many SharePoint users, some need additional capabilities regarding indexing if PDF documents, e.g. extraction of custom metadata from PDF's document
    information dictionary and embedded XMP metadata. PDFlib GmbH, the company I work form, sells an IFilter for PDF, and of course we would like to continue to offer this for SharePoint 2013.
    Thanks
    Stephan

    You should be able to replace it with any ifilter you want, this is the procedure for installing it:
    Install PDF iFilter 9.0 (64 bit) from
    http://www.adobe.com/support/downloads/detail.jsp?ftpID=4025 (http://www.adobe.com/support/downloads/detail.jsp?ftpID=4025)
    Download PDF icon picture from Adobe web site
    http://www.adobe.com/misc/linking.html (http://www.adobe.com/misc/linking.html)  and copy to C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\15\TEMPLATE\IMAGES\
    Add the following entry in docIcon.xml file, which can be found at: C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\15\TEMPLATE\XML
    <Mapping Key="pdf" Value="pdficon_small.png" />
    Add pdf file type on the File Type page under Search Service Application
    Open regedit
    Navigate to the following location:
    HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Office Server\15.0\Search\Setup\ContentIndexCommon\Filters\Extension
    Right-click > Click New > Key to create a new key for .pdf
    Add the following GUID in the default value
    {E8978DA6-047F-4E3D-9C78-CDBE46041603}
    •Restart the SharePoint Server Search 15
    •Reboot the SharePoint servers in Farm
    •Create a Test site (with any out-of-box site template) and create a document library upload any sample PDF document(s).
    •Perform FULL Crawl to get search result.
    Once the crawl is completed we will get search results.
    Kind regards,
    Margriet Bruggeman
    Lois & Clark IT Services
    web site: http://www.loisandclark.eu
    blog: http://www.sharepointdragons.com

  • Custom BIOS for GE60 2oc

    Hello!
    I would like to request a custom bios for my laptop (MSI GE-60 2oc).
    I have had problems with low CPU utilization after updating the embedded controller with official MSI firmware update. At the same time I was supposed to update the BIOS, but I couldn't, using the official driver found on MSI download center, since my system told me it's not the right version.
    I wanted to try this new approach as a new bios might help, I figured. I can't find any downgrading for the embedded controller. Would a custom bios be good thing for me or am I doing this all wrong?
    Current bios: E16GCIMS.509
    EC firmware installed: 16GCEMS1.506
    The BIOS update that did not work: E16GCIMS.611

    I know got my current version of BIOS and EC by MSI support so I will experiment with them. Downgrading to EC v. 5.00 helped I think. I have started to meassure now and the thing is that my GPU seems to have a real low core clock. The GT750m is marketed as 967 mhz but GPU shark and 3DMark 11 shows that I have 405 mhz. When playing Starcraft 2 I get real low FPS considering the settings (25 fps while playing medium quality and 1080p res.) hard to find comparing stats on the net. When meassuring with 3Dmark 11 I get a 2800 score which is comparable to other machines like mine.
    GPU Shark v0.7.3
    (C)2013 Geeks3D - www.geeks3d.com
    GPU Shark v.0.7.3 gives me these numbers:
    Elapsed time: 00:01:40
    OpenGL memory - total:2048MB, usage:98MB
    GPU 1 - GeForce GT 750M
    - GPU: unknown
    - Bus ID: 1
    - Device ID: 10DE- FE4
    - Subvendor: MSI (1462-10E6)
    - Driver version: 9.18.13.3182
    - NV driver branch: r331_00-187
    - OS: Windows 8 64-bit
    - Bios version: 80.07.a2.00.07
    - GPU memory size: 2048MB
    - Bus width: 128-bit
    - GPU memory location: GPU dedicated
    - GPU memory type: GDDR5
    - GPU temp: 43.0°C (min:43.0°C - max:45.0°C)
    - GPU cores: 384
    - Performance states: 3
    - Performance state P0
    - GPU: 1183.5MHz
    - Mem: 2355.0MHz
    - VDDC: 0.856V
    - Performance state P5
    - GPU: 1183.5MHz
    - Mem: 800.0MHz
    - VDDC: 0.850V
    - Performance state P8 (current)
    - GPU: 405.0MHz
    - Mem: 405.0MHz
    - VDDC: 0.806V
    - True current clock speeds / VDDC:
    - Core: 135.0MHz
    - Mem: 405.0MHz
    - VDDC: 0.806V
    - GPU and memory usage:
    - GPU: 0.0%, max: 99.0%
    - GPU memory: 4.7%
    - GPU memory controller: 0.0%
    - Limiting policies (NVIDIA):
    - no limitation
    - Current active 3D applications:
    ---- 3dmark11.exe (PID: 6360)
    ---- furmark.exe (PID: 6328)
    ---- gpushark.exe (PID: 7028)
    Well well, will try new BIOS now when I get go back to my previous version if it doesn't help me.

  • Custom report for TOP 10 CPU Utilization machines from any group in aggregation last seven days

    I want to create a custom report that contain list of TOP CPU Utilization of machines form any group.This report is create on last 7 days CPU utilization of all machine from a group.
    What  should be query for this report.

    Hi,
    Please refer to the links below:
    SQL Query for TOP 10 Average CPU
    https://social.technet.microsoft.com/Forums/systemcenter/en-US/8d9a2d0d-8761-4d1f-b194-b24aa65172e1/sql-query-for-top-10-average-cpu?forum=operationsmanagerreporting
    How to use Report Builder to create custom reports in SCOM 2007
    http://www.systemcentercentral.com/how-to-use-report-builder-to-create-custom-reports-in-scom-2007/
    Please remember to mark the replies as answers if they help and unmark them if they provide no help. If you have feedback for TechNet Subscriber Support, contact [email protected]

  • Custom Report for Asset Intelligence including Collection selection

    Dear all,
    I'm struggling with an custom report for doing the following thing.
    I have labeled software with the custom label 3 in the Asset Intelligence.
    I like to create a Report where i can Choose my Collection and then the Label that should be displayed.
    Similar to the Report: Software 10A - Software titles with specific multiple custom labels defined.
    But i like to choose more than one Label 3.
    Does anybody have something like that? Its really complicated for me to edit that report.
    Thanks & Regards
    Flat

    Hi,
    You could post this question in SQL forum to see if someone there can edit the report.
    The following document could help you to custom the report.
    Getting Started with Report Builder
    https://msdn.microsoft.com/en-us/library/dd220460.aspx
    Best Regards,
    Joyce
    Please remember to mark the replies as answers if they help and unmark them if they provide no help. If you have feedback for TechNet Subscriber Support, contact [email protected]

  • Return to vendor via delivery, customer number for each vendor?

    Hi
    We wish to use return materials to Vendor via delivery process
    addition to required configuration, we need to maintain Customer number in Vendor master
    In out plant we have more than 500 Vendor masters, do we need to create customer number for each vendor? or can we create a generic customer ????
    Business has a concern on creating customer for each vendor since number is huge, Sales guys may get confused with these numbers
    Please suggest a way out
    Thanks

    Thanks Jurgen for the reply
    We have Vendor Work flow setup in the system. Which means when ever vendor master is changed [Return indicator ticked] workflow kicks off which means it goes for approvals. This is why we dont want to go for tick as and when needed. When ever there is a return, return to vendor must be ticked, it will go for approval etc so it slows the process
    we are thinking if we can achieve through data load before SAP GO-Live so that users able to return without any delay
    NOTE 447070 says 'the automatic creation of the required customer data is not supported in the data transfer'
    this is related to automatic customer create isnt it
    i was thinking as below
    --> Create Ship-to's for all vendors
    --> Load vendors via LSMW [along with return to vendor ticked and customer number(created above)]
    Tested in SAP
    created ship-to
    Created vendor with above customer number
    Do you see any issue?
    Thanks

  • When will Adobe Reader for Mobile Devices support 3D PDF files?

    When will Adobe Reader for Mobile Devices support 3D PDF files?

    There are two basic varieties of LiveCycle XFA...Static XFA and Dynamic XFA, which are very different in terms of their future for potential support in Adobe Reader for iOS. Which variety of XFA are you using?
    Static XFA uses the PDF markup language for content and form fields, so users can view the documents in Adobe Reader for iOS, but we currently do not properly handle filling, saving, and submitting those forms. I have improving our handling of Static XFA on my roadmap, but cannot offer any specific date yet (sorry, policy plus actual uncertainty). I know that there are some other apps that partially support Static XFA, though I do not know how complete their support is. If you can even open the XFA document in Adobe Reader for iOS, it is likely Static XFA.
    Dynamic XFA is effectively a JavaScript application packaged inside a PDF wrapper, which generates layout and form fields via code and requires a significant engine to support this. Support for Dynamic XFA is unfortunately not currently on our roadmap for iOS due to the nature of the technology, and our concern that any implementation we try likely will not pass Apple's restriction against installing something that allows other "apps" to be downloaded and executed from within it. The LiveCycle team is exploring solutions for our enterprise customers wanting to use Dynamic XFA from mobile devices as part of their server offering, but I cannot offer any insight here. To my knowledge, there are no applications that handle Dynamic XFA other than Adobe Reader for the desktop platforms (Windows, Mac, Linux).
    Dennis

  • Customer conversion for Non-English languages

    Hi:
    We have a requirement to convert customer data from lagacy system to Oracle EBS supporting English and Non-English languages. Our conversion programs for english is working fine but we are not sure about the approach for other language converions. Can anyboody share the knowledge if faced similar requirements?
    Thanks /Santanu

    Duplicate thread (please post only once) ...
    Customer conversion for non-english language
    Re: Customer conversion for non-english language

  • Description of key figure for multi language support issue.

    Hi Experts,
    Have a good day ahead!!
    Custom key figure description multi for the language support issue
    The key figure is created in English  language and description also in English.
    When I have logged in to English language and checked the report in Bex ,description of key figure is available.
    But when I log in to other language(German, Spanish Portuguese and etc) environment the description in Bex rport of key figure is showing blank
    In rsa1 in both English and other(German, Spanish Portuguese and etc)  environments key figure description is okay and correctly displaying.
    Please post me your inputs on the same.
    Thanks in advance!!
    Regards
    Priya.

    Hi Prasanth,
    This are the key figures XPRECIO: Transactional Price and XPRECLIST: Price list, its maintained in RSA1 tcode at info object level .
    These two KF descriptions are maintained in English, its working fine when I login into SAP Bex analyzer with English language and its not showing the description for the languages (German, Spanish, Portuguese and etc).
    Its need to be displayed in when login into SAP Bex analyzer with language German, Spanish, Portuguese and etc.
    Regards
    Priya

Maybe you are looking for

  • Reading and Writing to a Log file

    Hello, I'm writing a class that will write a user id to a log file every time they click on a particular button. However, I don't want a new line every time a user clicks on the button, I'd like to be able to find their id in the log, increment a cou

  • Short Dump  while scrolling on the ALV (GETWA_NOT_ASSIGNED)

    Hi All, I have an interactive ALV list, After the user double click on the list line item, the list control goes to top of the list. When i want to scroll  for further interaction, I am getting  a Short dump  GETWA_NOT_ASSIGNED. Please advice Solomon

  • HP 2311x monitor connecting to HP G60 laptop

    I  have a HP 2311x monitor that I would like to connect to my HP G60 laptop.  Monitor is showing 'no connetion signal' and goes to sleep almost immediately. 1. Is it possible to set these two up for connection? 2. How do I connect? Thanks!

  • I stopped installation, wont work.

    hey, i dont know if this is a common issue or not but i searched for it and couldnt find an answer....so here's what happened. I finally started to install version 10.4.11 from the Software Update. it was taking forever and i had to turn off my insta

  • Error while calling Custom activity Hook

    Hello ME and MII Experts, We are tying to call custom MII transaction via Activity hook at operation level. While doing that, we received the error "The resource "SAPMEWIP" does not support two-phase commit and cannot be enlisted in the current trans