Document events for text replacement
Hello!
This is a question about Document events in JTextComponent.
Two document events in a row are fired when the user performs a text replacement (some text is selected and the user inserts or pastes new text): first, DocumentListener.removeUpdate is called for the selected text being removed; second, insertUpdate for the text being inserted or pasted.
The question is: how can I be aware that both events are related and exist in response for the same and unique action?
More specifically, I need to know that the remove event is part of a two-step edition in order to bypass execution flow.
I have some bizarre ideas in mind, like proxing the original ActionMap "paste" action (for pasting) and tracking the keyboard (for inserting), but I don't think this is a too elegant approach.
Please let me know if you would find helpful some sample code.
Thank you!
That's from JTextComponent replaceSelection() method source
public void replaceSelection(String content) {
Document doc = getDocument();
if (doc != null) {
if (doc instanceof AbstractDocument) {
((AbstractDocument)doc).replace(p0, p1 - p0, content,null);
else {
if (p0 != p1) {
doc.remove(p0, p1 - p0);
if (content != null && content.length() > 0) {
doc.insertString(p0, content, null);
...As you can see it calls ((AbstractDocument)doc).replace() in the most cases all the default EditorKits uses AbstractDocument extensions.
Then from AbstractDocument's replace
public void replace(int offset, int length, String text,
AttributeSet attrs) throws BadLocationException {
DocumentFilter filter = getDocumentFilter();
if (filter != null) {
filter.replace(getFilterBypass(), offset, length, text,
attrs);So I think you can set your own DocumentFilter and override the filter's replace. Set the flag replaceStarted=true and call super.replace(). In the DocumentListener just check the flag.
Similar Messages
-
Hi Experts,
Is it possible to trigger an event , such that when one of the data in textview is double clicked , in the event i want to capture the value of the data
that was double clicked , for example if I have a data '20' , it should trigger an event when it is double clicked and in the event is should be able to hold the value of 20
and pass this to some local variable for further processing .Please let me know if this is possible .
Note: TextView is created dynamically
Regards,
SanjuHi Sanju,
As per my knowledge there is no action available for Text view in Web Dynpro for ABAP.If you want to know about this you can check in this class CL_WD_TEXT_VIEW here you dont any have method of thpe Event Handler.
Also check properties of Text view you dont have any action for this UI element.
Thanks
Suman -
Header text in document header for DEBIT memo
Hi,
In the document header for credit memo (T-Code:- VA01) i do have pane/window called header text but when i create the debit memo with the same t-code, header text doe snot show up.
Can somebody please show me where to configure this setting for debit memo?
Thanks in advance
Regards
HrishiHi,
Could you check if you have implemented BADI AC_DOCUMENT in your system?
If BADI AC_DOCUMENT is activated then in both methods CHANGE_INITIAL
and CHANGE_AFTER_CHECK of badi, following code line must be present.
MOVE-CORRESPONDING im_document-header to ex_document-header.
Regards,
Ashwini. -
Mouse over event for every word inside a text?
I want to do a separate mouse over event for every word inside a text.
or at least get the string below the mouse cursor.
any hint?
henryThere are no events for it but you can use TextField.getCharIndexAtPoint() to determine the character where the mouse is over, and from there you can work out the word where the mouse is over.
-
Text Replacement for Period Interval
Hello All,
I need to create a Text Replacement for a Period Interval. Can anyone tell me how to do this? Or point me to white paper on the subject.
Thanks
MKCreate 2 text variables(T1& T2) processing type as replacement path. For T1 set the option as "From" for use interval and for T2 set the option as "To" for use interval. Then you can use the header as T1-T2. This should solve your problem.
Assign points if you find this helpful. -
Utilities:Events for device installation and replacement
Hi all,
i need to know the events for device installation and device installation replacement.
please help urgent help required.
Thanks,
Anand.>events for device installation
1. An installation order for a device or a device group is created in the Service Management (PM-SMA) application component. This may result from a company requirement (such as a switching change) or an external requirement (new connection),
2. The installation order is executed and returned.
3. The removal of the device is entered in IS-U.
>device installation replacement
1. A replacement order is created for a device or a device group in the Service Management (PM-SMA) application component. This may result from a company requirement (such as a switching change) or an external requirement (such as a change in use of the object).
2. The replacement order is executed and confirmed.
3. The replacement of the device or of all devices in a device group is entered in IS-U.
Regards,
Dharani -
Event for document type immediate payment
Dear all,
We are having one requirement where we need to make the payments immediately .For this i have created one new document type particularly for for immediate payments.Can anybody tell me in which event we can substitute this document type while processing invoice document
susmitaHi ,
First of all let us understand that the due date for net payment is considered from the payment terms that are being defined in the contract account , which in addition considers the payment terms of FI ( accounts receivable and payable ) and calander as defined in the payment term .
If the requirement is that the payment terms should be immediate for a particular document type and in in rest document types it should consider the one mentioned in contract account .
In that case you can user any of the event which gets fired at the time of posting of FICA document , check for events pertaining to posting of document and write a custom code for substituting the payment terms for specific document types .
It would be more clear if you specifiy that from where are you posting the document . is it FPE1 or at the time of invoicing or through sanding request ?
Hope this suffices .
Cheers ,
Dewang -
Can i search multiple sheets in a document for text in column a to return the entire row if column a matches in a
separate sheet?Thank you, Barry. That was helpful, and am hopeful that what I want to do is possible.
I am creating a spreadsheet that currently has 20 sheets, of which certain sheets have more than one table. I will be adding more sheets. I would like to return results for all occurences of the search string. Preferably into a seperate spreadsheet. It would be perfect if that seperate sheet updated whenever I update information in the first spreadsheet. To give an example:
Sheet: baskets
Tables: straw
wire
Sheet: barware
Tables: glasses
decanters
coasters
My tables all have the same titiels:
Vendor Description Cost Selling Price
Since I will have upwards of 100 sheets, with multiple tables, and most of my vendors will fit into multiple sheet categories, it would be helpful if I could also see what my order will be from each vendor, not just who I will be ordering each item from. How would I do that?
I hope I conveyed that properly.
Thank you in advance for your help,
Rana -
Where to find out Text for document storage for HR Objects in E-Recruitment
Hi,
In E-Recruitment
1.For table HRP5121,there are some fields which store numeric values but points to a text in the document storage for HR Objects. Where can we find out the description for the text ?
2.Similarly for Resume attachment is there any way where we can find out where the resume or other documents are stored
For pt 1 Requirement is to create a reportIf i am not wrong, resume attached would be stored in tables TOAHR and SDOKCONT1, and attached document can be accessed through PB30 --> Extras
-
Recently the sound on my Iphone 4 for texts, and email alerts started working intermittently. I have upgraded to the latest software and the Apple store even replaced the phone but safe issues
For each mail account, along with designating a primary SMTP server, you should be able to just turn off any and all other SMTP servers you have listed. In that case, if there is a problem with comcast, the message send should just fail.
Also make sure your comcast smtp settings are correct (port, likely 587 but might be something else for comcast, whether you should be suing SSL or not, do you need authentication or not).
You might find the comcast forums useful for getting the settings right - I found this:
http://forums.comcast.com/t5/E-Mail-and-Xfinity-Connect-Help/iphone-email/m-p/66 1151?view=by_date_ascending#M131151
The second poster notes, SSL should be on, authentication should be "password" and you should be using port 995 -
Hello All,
We have an requirement to find out the FQ event for FI-AP Document with Doc type IF. We couldnt find the from FIBF. Can you please help us.
Regards
Balakumar L SHi Balakumar,
FQ means
Regards
Mani -
Looking for a replacement calendar
Does anyone know if there is a replacement calendar app where I can open up the appontment box on tapping the time I want to make the appontment? (ie like the Blackberry method)
I want to bypass the default process of tapping the +, then fill in the appontment, then the start time, then the finish time...surely others feel the same, no?I'm spoiled. The app I currently use has dozens of useful features, such as:
*Multiple categories
*Filtering by category
*Templates to create commonly used events
*Day, 3 day, Week, graphical week, month, 4 month and yearly views
*Integrated tasks display
*Advance notices for selected events (e.g., for anniversaries)
*Saved views that have specific preference settings
*Creating a group of related events
*Floating events that move from day to day until checked off
*Filtering on any setting or text in a set of events
*Manipulating the results of a filtered set as a group, to archive, delete, etc
*Setting font, color and icons for events and the templates that create them
*Linking events to contacts, notes, tasks and other events (for example, linking the contact entries for all participants in a meeting to the meeting entry - Interesting that the Apple Newton had this, but not the iPhone)
This is only a short list of features that I use on a daily basis. I've had them for 10 years on a Palm, and will not give them up, even for an iPhone. I still carry a Palm, and I will switch to the first device that supports this app even if it has nothing else. -
Text Replacement in scanned page question
I must be doing something incredibly wrong because I cannot get text to be replaced in a scanned OCR document. I am using Acrobat Pro 9.
Before getting to that, let me ask this question: If I am scanning a document created using a readily available font like Times New Roman, why does Acrobat even bother using the scanned page for displaying text? It knows the text, the OCR was 100% accurate. Why not replace the 300 dpi scanned bitmap image with real, vector-based text? I don't understand that.
OK, now to just trying to replace what amounts to fuzzy looking text with vector text. I've read how to replace text using Tools-> Advanced Editing-> TouchUp Text Tool where I select text, right click on it, go to properties and change the text. Here's what happens when I do that:
First off, the defaults in the properties dialog are set to no fill and no stroke. Why is that? If you're changing your font, wouldn't you want it to show?
After making a selection and closing the dialog, the text indeed changes, but the original, fuzzy text is there as well. And, as there are slight differences in font size, the page is virtually unreadable as it has the appearance of being printed twice with different alignments each time.
This is, of course, quite useless. I MUST be doing something wrong.
Of course, taking even this course of action is pretty frustrating, as the document I'm working on has many statements in bold, so doing a global font change isn't even practical. I really just wish acrobat would know that it can display vector text from the get-go, and forego the bitmapped text altogether.
Thanks, I hope my frustration isn't too evident!
Grahamplease delete me from your mailing list. tks.
Date: Wed, 10 Feb 2010 10:01:23 -0700
From: [email protected]
To: [email protected]
Subject: Text Replacement in scanned page question
I must be doing something incredibly wrong because I cannot get text to be replaced in a scanned OCR document. I am using Acrobat Pro 9.
Before getting to that, let me ask this question: If I am scanning a document created using a readily available font like Times New Roman, why does Acrobat even bother using the scanned page for displaying text? It knows the text, the OCR was 100% accurate. Why not replace the 300 dpi scanned bitmap image with real, vector-based text? I don't understand that.
OK, now to just trying to replace what amounts to fuzzy looking text with vector text. I've read how to replace text using Tools-> Advanced Editing-> TouchUp Text Tool where I select text, right click on it, go to properties and change the text. Here's what happens when I do that:
1. First off, the defaults in the properties dialog are set to no fill and no stroke. Why is that? If you're changing your font, wouldn't you want it to show?
2. After making a selection and closing the dialog, the text indeed changes, but the original, fuzzy text is there as well. It is as if there is a bitmapped image sitting behind my new, pristine text.
This is, of course, quite useless. I MUST be doing something wrong.
Of course, taking even this course of action is pretty frustrating, as the document I'm working on has many statements in bold, so doing a global font change isn't even practical. I really just wish acrobat would know that it can display vector text from the get-go, and forego the bitmapped text altogether.
Thanks, I hope my frustration isn't too evident!
Graham
> -
I have an 800 page pdf document to index and so far I have a script that will search for a list of keywords. But the text has large sections of code in a different font, and I think we would like to generate an index of just code examples. Is there a way to search for text of a given font in applescript? Something like
set theSel to find text theText
if the font of theSel is "Times"
write to file, etc.Please do send a page, I might be able to spot where the font problem is coming from - but no guarantee Address is in my profile.
You asked about the script formatter. red_menace of this forum wrote the script I use. To use it, you copy the script that you want to format to the clipboard and run the formatter. This then places the marked-up text in the clipboard so that you can paste it into the forum page.
<pre style="
font-family: Monaco, 'Courier New', Courier, monospace;
font-size: 10px;
margin: 0px;
padding: 5px;
border: 1px solid #000000;
width: 720px; height: 340px;
color: #000000;
background-color: #FFDDFF;
overflow: auto;">
script formatter - formats the clipboard text for forum posting
last reviewed January 19, 2009 red_menace[at]mac[dot]com
Input: text read from the clipboard
Output: formatted text copied to the clipboard
set AppleScript's text item delimiters to " "
-- some constants and switches
property TextColor : "#000000" -- black (see http://www.w3schools.com/tags/ref_colornames.asp)
property BackgroundColor : "#FFDDFF" -- a light plum/purple
property BorderColor : "#000000" -- black
property TheWidth : "width: 720px; " -- a width attribute (deprecated in HTML 4.01)
property UseWidth : true -- use the width attribute?
property LineCount : 25 -- the number of lines before including the height attribute
property TheHeight : "height: " & ((LineCount * 13.6) as integer) & "px; " -- a maximum height for the <pre> box
property Emphasize : false -- emphasise (bold) the script text?
property UseURL : false -- include a Script Editor message link?
property AltURL : false -- use an alternate URL encoding?
property ToolTips : {¬
"this text can be pasted into the Script Editor", ¬
"this text can be pasted into an Automator 'Run AppleScript' action", ¬
"this text can be pasted into an Automator 'Run Shell Script' action", ¬
"this text can be pasted into a HTML editor", ¬
"this text can be pasted into a text editor", ¬
"- none -"}
property TooltipDefault : {item 1 of ToolTips} -- keep track of the last tooltip used
property TempFile : "Script_Formatter_TempFile" -- a temporary work file
try
-- write the clipboard to the temporary file
set TheClipboard to (the clipboard) as text
if TheClipboard is in {"", space, tab, return} then return -- clipboard is (basically) empty
set MyOpenFile to open for access ("/tmp/" & TempFile & ".txt" as POSIX file) with write permission
set eof of MyOpenFile to 0 -- empty any previous temp file
write TheClipboard to MyOpenFile
close access MyOpenFile
if UseURL then
-- encode URL (see http://developer.apple.com/documentation/Darwin/Reference/Manpages/man1/pydoc.1. html)
do shell script "/usr/bin/python -c 'import sys, urllib; print urllib.quote(sys.argv[1])' " & quoted form of TheClipboard
-- add a link wrapper
set URLtext to "applescript://com.apple.scripteditor?action=new&script=" & the result
if AltURL then -- use an alternate URL encoding
set URLtext to "Click here to [url=" & URLtext & "]open this script in the Script Editor[/url]:<br />"
else -- use HTML anchor tag
set URLtext to "Click here to <a href=\"" & URLtext & "\">open this script in the Script Editor</a>:<br />"
end if
set PromptText to ((count URLtext) as text) & " URL and "
else
set {URLtext, PromptText} to {"", ""}
end if -- UseURL
-- convert to HTML (see http://developer.apple.com/documentation/Darwin/Reference/ManPages/man1/textutil .1.html)
do shell script "cd /tmp/; /usr/bin/textutil -convert html -excludedelements '(html, head, title, body, p, span, font)' -encoding US-ASCII " & TempFile & ".txt"
-- fix up some formatting and add a pre wrapper (see http://www.w3schools.com/tags/default.asp)
set HTMLtext to rest of paragraphs of (read ("/tmp/" & TempFile & ".html" as POSIX file))
if (count HTMLtext) is less than LineCount then -- skip the height attribute
set Height to ""
else
set Height to TheHeight
end if
set HTMLtext to FixCharacters from (HTMLtext as text) -- additional character encodings
if UseWidth then
set Width to TheWidth
else
set Width to ""
end if
if Emphasize then set HTMLtext to "<strong>" & HTMLtext & "</strong>"
set HTMLtext to "<pre style=\"
font-family: Monaco, 'Courier New', Courier, monospace;
font-size: 10px;
margin: 0px;
padding: 5px;
border: 1px solid " & BorderColor & ";
" & Width & Height & "
color: " & TextColor & ";
background-color: " & BackgroundColor & ";
overflow: auto;\"
title=\"\">
" & HTMLtext & "</pre>
-- assemble everything on the clipboard
set TheResult to choose from list ToolTips ¬
with title "Script Formatted" with prompt PromptText & ((count HTMLtext) as text) & " HTML characters will be placed on the clipboard (plus the following ToolTip):" default items TooltipDefault OK button name "OK" cancel button name "Cancel" with empty selection allowed without multiple selections allowed
if TheResult is false then -- cancel button
error number -128
else -- add the selected title attribute (tooltip), if any
set TooltipDefault to TheResult as text
set Here to (offset of " title=" in HTMLtext) - 1
set There to (offset of ">" in HTMLtext) - 1
if TheResult is in {{}, "- none -"} then -- no tooltip
set the clipboard to URLtext & (text 1 thru (Here - 1) of HTMLtext) & (text (There + 1) thru -1 of HTMLtext)
else
set the clipboard to URLtext & (text 1 thru (Here + 9) of HTMLtext) & TheResult & (text There thru -1 of HTMLtext)
end if
end if -- TheResult is false
on error ErrorMessage number ErrorNumber
log space & (ErrorNumber as text) & ":" & tab & ErrorMessage
try
close access MyOpenFile
end try
if (ErrorNumber is -128) or (ErrorNumber is -1711) then -- nothing (user cancelled)
else
activate me
display alert "Error " & (ErrorNumber as text) message ErrorMessage as warning buttons {"OK"} default button "OK"
end if
end try
to FixCharacters from TheText
fixes (converts) formatting characters used in some message forums (see http://www.asciitable.com/)
parameters - TheText [text]: the text to fix
returns [text]: the fixed text
-- this list of lists contains the characters to encode - item 1 is the character, item 2 is the HTML encoding
set TheCharacters to {¬
{"!", "!"}, ¬
{"*", "*"}, ¬
{"+", "+"}, ¬
{"-", "-"}, ¬
{"[", "["}, ¬
{"\\", "\"}, ¬
{"]", "]"}, ¬
{"^", "^"}, ¬
{"_", "_"}, ¬
{"~", "~"}}
set TempTID to AppleScript's text item delimiters
repeat with SomeCharacter in TheCharacters
if item 1 of SomeCharacter is in TheText then -- replace
set AppleScript's text item delimiters to item 1 of SomeCharacter
set the ItemList to text items of TheText
set AppleScript's text item delimiters to item 2 of SomeCharacter
set TheText to the ItemList as text
end if
end repeat
set AppleScript's text item delimiters to TempTID
return TheText
end FixCharacters
</pre> -
Converting text in Draw document to editable Text in Word Processing
I have created a Draw document consisting of photographs and text. I now want to send the text only to a colleague for sub-editing. How do I convert the one to the other, please?
The easy way:
--[SCRIPT extractRawTextFromAWdraw]
Open an AppleWorks Draw document
run the script.
You will get on the Desktop a text file entitled
"extractedRawText.txt"
containing the document's raw text.
Yvan KOENIG (Vallauris, FRANCE)
2009/07/03
on run
tell application "AppleWorks 6"
activate
tell document 1
set textBoxes to get text frames
set rawText to ""
if textBoxes is not {} then
repeat with i from 1 to count of textBoxes
set rawText to rawText & "text frame #" & i & return & text body of item 1 of textBoxes & return & return
end repeat
end if
end tell -- document
end tell -- Appleworks
if rawText is not "" then
set nomDuRapport to "extractedRawText.txt"
set p2d to path to desktop
set p2r to (p2d as text) & nomDuRapport
tell application "System Events"
if exists (file p2r) then delete (file p2r)
make new file at end of p2d with properties {name:nomDuRapport}
end tell -- System Events
write (rawText as text) to (p2r as alias)
end if
end run
--[/SCRIPT]
Yvan KOENIG (from FRANCE lundi 3 août 2009 11:17:20)
Maybe you are looking for
-
Hi all. I`m configuring new 2504. I updated it to 7.4.100.60 and enabled LAG. I want to configure interfaces "ap-mgmt" - for AP management. (Cisco Controller) >config interface create ap-mgmt 69 (Cisco Controller) >config interface address dynamic-in
-
I've got a digital camera which uses Quick Time (for Windows) to play back 'movies' I've recorded on it. If I upgrade to Quick Time Pro for Windows will I be able to convert and export the Quick Time files to a format that my DVD players can recogniz
-
Mapping EUS groups to shared schema
Hi, everybody Has anybody done such thing ? I tried to map "cn=test_group,cn=groups,dc=test,dc=com" to schema GLOBAL_SCHEMA by ESM on target database but it silently skip my action. Moreover, I haven't found in documentation any mention about mapping
-
Urgent help on amortization - DBT_B002
HI have got held up in my config for bonds. I have created an amortization procedure 02 LAC N NET 1. Amortization to end (have also tried with 4) I assigned to position management procedure. 1. sec/loan 02. Post only to used coponent Step 1. Amortiza
-
Album starter ed. 3.2 won't let me copy/paste pictures
photoshop album starter edition 3.2, winxp home, dell dimension 5100, lexmark x3350, 3gig ram. this program will not allow me to copy/paste any pictures from MY PICTURES/DOCUMENTS. they all go into the photoshop program and i have to right click on t