Search & Replace function in Files?

Does there exist a "Search & Replace String" function for Files IO? ...preferable RandomAccessFile.
Or do I have to make my own parser from scratch.
Anyone know of free code that exists somewhere? This seems like a function that someone must have made at least or has a use for.
Thanks for any! :)
rasmasyean

The JDeveloper Editor provides Search & Replace functionality for files.
What I typically do is
Select menu: Search | Search Source Path...
Enter Search String and Change Source path
and other fields and press Start
Then the Navigator displays a Search tab which lists all files with the matching string.
Double click on first file in navigator and
select menu Search | Replace
In this dialog enter your search, replace, and other options-
In the Options, If you do not want to be prompted, do not check the Prompt on replace option.
Select the Scope of Global
Selectg the Origin of Entire
When you are ready press the Multiple button to make multiple replacements.
When you are done with this file,
Press Ctrl-S to Save the file
Press Ctrl-F4 to close the window
Double click on the Next File
Press Ctrl-R to invoke the Search | Replace dialog.
You should not need to change any options.
Press Alt-M to select the Multiple Button!
While this may seem more complex then a simple Sed / Perl / Python script, it is more controllable, flexible and user friendly.
Besides, you may learn a few JDeveloper tricks.
Good Luck,
-John

Similar Messages

  • TestStand Design Search/Replace Functionality

    We are in the process of changing from using Measurement Studio/Visual Basic to using TestStand as the test executor. (We are just learning to use TestStand and LabView.)
    Currently, all testing is done using VB as the low level calls, and VB scripting for the test automation.
    Our plan is to start by putting the VB low level code into an Active-X DLL and as time permits, move the low level code to LabView.
    The question is, as we create replacement functions using LabView, how do we Replace the Active-X DLL calls with the LabView functions?
    My first thought was to use "Search and Replace" (as there is in most other language enviornments) but I can't find such a function in TestStand. IS THERE A WAY TO DO THIS?
    M
    y other thought is to somehow create a subsequence for EACH library call that points to a single block for that function, where that single block can be changed from the Active-X DLL call to a LabView call.
    Examples would be that we have a Read/Write Parameter function as:
    ReturnStatus=DLL_Parameter(Name,Instance,Value,Mode)
    We would eventually create a new function in Labview and would want to replace ALL instances of the DLL call with a similar LabView function.
    How do we design this in?
    Mikef

    Unfortunately a search/replace feature has only been introduced in the new TestStand V3.0. It allows for searching and some replacing of values, properties, etc. however this may not help what you are describing.
    It is possible to write you own custom search/replace code that uses the TestStand API and can scan through a sequence file for particular step names or types and then insert a new LabView Step and remove the old DLL call step.
    If you need to keep the DLL parameters you can access them using the Step.TS.SData cluster. (You may need to set the �Show Hidden Properties� in the Station Options to see this in the Sequence Editor).
    Check out the TestStand API Reference and some of the Examples included in TestStand on how to use it.
    Hope this helps
    Simon Holman
    Simon Holman
    Software Engineer
    Certified LabVIEW Developer
    Certified TestStand Developer
    measX GmbH & Co. KG.
    http://www.measx.com

  • Search/replace in huge files without line breaks

    i need to search and replace in huge XML files not containing line breaks. i cannot load them to memory as a whole because of size and cannot write a simple GrepReader because the $%��*" legacy system exporting the files does not do line breaking
    plz help

    P.S.
    the files are looking similar to XML, they are not XML at all - thats the original reason i have to modify them, no parser will accept them. aka: plz do not suggest SAX-parsing...

  • Search/replace function for Lightroom?

    I am trying to find out if there is a way of finding and replacing certain text in the metadata in a quick and easy way. I need to change something on all my photos in LR. Can anyone help me? Thanks a lot in advance.

    Rob,
    Thanks for response.
    I understand that Lightroom has a  SDK for plugins and this is a really good thing as it does allows others to tweak and enhance functionality without relying on Adobe. I have been a user of Lightroom  since the very first user trials and think it is a great product. I have watched it develop over the last 5 or 6 years.
    I do think it is more than just an image editor. Lightroom has always been promoted since day one as a new and better image database and workflow management tool. It is for this reason that question why Adobe has not closed some (I think) gaps in functionality consistent with Lightroom fullfilling its purpose as an Image library/Database management tool. It has certainly had the search capabilities included since day one of all metadata, consistent with a management tool.
    For the work I have been doing lately, Search and replace would be useful as I have been cleaning up metadata in various libraries. Hence while I agree it is not used every day, it would be a very useful maintenance tool.
    I thought I had posted this originally as a response to a similra request in the Lightroom Feature request forum, apparently not. I did try (today) to start a new feature request  but I was blocked from starting new threads in that sub-forum. Hopefully someone else with access to that forum will pick up on this and transfer the request to the Feature Request forum.

  • Search / Replace on other Files Types

    When do a mass search using DW CS3 and search on a directory,
    the search ignore certain file extension such as .properties. How
    can I tell the DW to search on ALL files or modify the files
    extension list that the program searches on?

    Read up on "Regular Expressions"
    "indonaught" <[email protected]> wrote in
    message
    news:ff892l$cv3$[email protected]..
    > When do a mass search using DW CS3 and search on a
    directory, the search
    > ignore
    > certain file extension such as .properties. How can I
    tell the DW to
    > search on
    > ALL files or modify the files extension list that the
    program searches on?
    >

  • Replace function in JDeveloper 3.2

    Hi JDev Team:
    Are there any global replace functions in JDev 3.2, for instance I have one word, say 'aaaa', in all of my projct files, .jsp, .java, .... I like to replace with 'bbbb'.
    Thanks

    The JDeveloper Editor provides Search & Replace functionality for files.
    What I typically do is
    Select menu: Search | Search Source Path...
    Enter Search String and Change Source path
    and other fields and press Start
    Then the Navigator displays a Search tab which lists all files with the matching string.
    Double click on first file in navigator and
    select menu Search | Replace
    In this dialog enter your search, replace, and other options-
    In the Options, If you do not want to be prompted, do not check the Prompt on replace option.
    Select the Scope of Global
    Selectg the Origin of Entire
    When you are ready press the Multiple button to make multiple replacements.
    When you are done with this file,
    Press Ctrl-S to Save the file
    Press Ctrl-F4 to close the window
    Double click on the Next File
    Press Ctrl-R to invoke the Search | Replace dialog.
    You should not need to change any options.
    Press Alt-M to select the Multiple Button!
    While this may seem more complex then a simple Sed / Perl / Python script, it is more controllable, flexible and user friendly.
    Besides, you may learn a few JDeveloper tricks.
    Good Luck,
    -John

  • [DW CC] Batch Search & Replace

    The GUI of the function search & replace does not offer any batch processes.
    Only one single search&replace could be saved and performed.
    Is there any way to perform a batch job via regular expressions in a file which can be applied?
    And to same different scopes (as in the GUI)?
    current document
    open documents
    folder
    marked files
    complete site
    text
    source code
    Is there may be an extensions which pimps the search&replace function?
    That's one of my mostly missed features since a long time.
    If you have a hint for me, I would appreciate that a lot.
    Thanks!

    mistershortcut wrote:
    That is not a rhetorical question. I'm really interested in your way of working with complex sites, with many documents to edit, ...
    I usually use PHP includes to avoid having complex sites with many documents to edit.
    Generally speaking, I can completely modify the layout of my entire site by editing a handful of includes, then uploading them. If I have repetitive content in many locations, it's either coming from the same place in a database or added by an include. Either way, a simple change to the include or data takes care of it.
    It's pretty rare for a site I create to have more than about 10-15 actual  pages. When they get larger than that, I typically convert them to being dynamically driven (php and mysql).

  • CF Search/Replace bug?

    First off, I run CFB2 as a plugin to FB 4.5 on Win7 64bit.  All was working properly until I installed the FB 4.6 release.  Now, my "ColdFusion Search" no longer performs a replace.  When I hit CTL+F I get the ColdFusion Search dialog like normal, type in my search criteria and hit Find it finds a match.  If I hit Find All it finds all matches.  So far so good.  Now if I hit Replace All it does the search, but then I never get the "ColdFusion Replace Dialog".  It just opens up my search view and shows my matches.  Even if I use a single Replace it does not replace.
    I've uninstalled FB 4.6 and CFB2 completely and re-installed and have the same problem.  When I uninstall FB 4.6 and CFB2 then re-install with FB 4.5 and CFB2 the problem goes away.
    Note: I have tried with and without the CFB2 hotfix 1 with same results.
    So, am I the only one or should I log a bug report?  I really want to use the new FB 4.6 features for our Air3 development, but can't sacrifice something as critical as a search/replace function on my CF stuff, and two standalone installs would defeat the purpose of having the IDE built on Eclipse.

    I, too, am more than a little annoyed at the problematic "Find' function in files opened via RDS. The only way to get it to actually find anything is to do a replace on the same term!  When I try to "Find All" I get a "No open file." message.  The hotfix has done nothing to fix this problem.
    HELP!

  • Search & replace text programmatically in pdf file

    I need to search & replace text programmatically (preferably in .NET c#) in existing pdf file.
    Does anyone know how to do it (maybe with with Acrobat SDK) ?
    Thanks in advance!
    A.
    PS: Well done working example :-)

    Searching APIs are provided, but there no APIs for replacing since that's not a standard operation on a PDF (given the rendering model).

  • Joker characters in the search and replace function

    Hello everyone,
    Just a quick question :
    I was wondering what character can be used as a joker character in the search and replace function (I did a research in the site, but didn't find any thread)
    To be clear, I have misspelled a word, for example «trouser».
    I know I didn't make any mistake with the first and last letter, but sometimes I wrote it «tourser», «turoser»
    (sorry if there is a weird meaning, i'm french, and for me it won't mean anything, so don't take it personally)
    I would like to be able te replace all the versions of «trouser», even the good ones, using «t*****r» in the search and replace function.
    I tried the «*» character, but it's not the jocker.
    Thank you for your help !

    As I can't edit my first message, just wanted to let you know it's also called «wildcard» characters
    Like here (Careful, it's… Ms Office)

  • Can I do a find and replace on .cfm files only and not search .html or .txt?

    Hi.  I'm using Dreamweaver CS4.  I would like to do a find and replace through my site with Dreamweaver but I only want it to search through .cfm files.  Currently it is searching through .html and .txt files along with .cfm.  Is there a way to do a find and replace on just .cfm files?
    - Tom

    You can't do it on just one type of file. However, you can do find and replace in selected files. Ctrl-click to select the targeted files in the Files panel, and then choose Selected Files in Site from the Find In drop-down.

  • Replace function for changing file endings

    Hello,
    I would like to replace the following file endings into *.TRC:
    my_first.ERR
    my_second.err
    my_third.ERR
    my_fourth.ERR
    my_fifth.err
    But, I am getting the following:
    my_first.TRC
    my_second.err
    my_third.TRC
    my_fourth.TRC
    my_fifth.err
    My sql statement
    update errorlog a
    set (err_file) =
    (select replace(err_file,'.ERR','.TRC')
    from errorlog b
    where a.err_id = b.err_id);
    The compiler does not like the follwing sql statement.
    I am getting an ORA-00907: ... Error.
    update errorlog a
    set (UPPER(err_file)) =
    (select replace(err_file,'.ERR','.TRC')
    from errorlog b
    where a.err_id = b.err_id);
    Does anybody have an idea?
    Best regards,
    Tom Rakete

    or something like.
    SQL> select * from errorlog;
    ERR_FILE
    my_first.ERR
    my_second.err
    my_third.ERR
    my_fourth.ERR
    my_fifth.err
    my_first.log
    6 rows selected.
    SQL> update errorlog
      2     set err_file = decode(substr(err_file,instr(err_file,'.',-1)),
      3                             '.err',substr(err_file,1,instr(err_file,'.',-1))||'TRC',
      4                             '.ERR',substr(err_file,1,instr(err_file,'.',-1))||'TRC',
      5                                    err_file);
    6 rows updated.
    SQL> select * from errorlog;
    ERR_FILE
    my_first.TRC
    my_second.TRC
    my_third.TRC
    my_fourth.TRC
    my_fifth.TRC
    my_first.log
    6 rows selected.
    SQL>

  • Search replace Word doc - Getting Erro : org.eclipse.swt.SWTException:

    Hi
    All
    I'm runing this Java class by a jsp to Search and Replace and saveAs a word document, when run the fisrt time it works OK, but if I run again I got this error:
    What is happing there?
    Following the Error and Source Java.
    Thanks
    11:59:49,234 ERROR [[jsp]] Servlet.service() for servlet jsp threw exception
    org.eclipse.swt.SWTException: Invalid thread access
    at org.eclipse.swt.SWT.error(SWT.java:3563)
    at org.eclipse.swt.SWT.error(SWT.java:3481)
    at org.eclipse.swt.SWT.error(SWT.java:3452)
    at org.eclipse.swt.widgets.Widget.error(Widget.java:432)
    at org.eclipse.swt.widgets.Shell.<init>(Shell.java:274)
    at org.eclipse.swt.widgets.Shell.<init>(Shell.java:265)
    at org.eclipse.swt.widgets.Shell.<init>(Shell.java:218)
    at org.eclipse.swt.widgets.Shell.<init>(Shell.java:156)
    at br.com.tryblob.view.WordSearchReplace.<init>(WordSearchReplace.java:36)
    at org.apache.jsp.replacedoc_jsp._jspService(replacedoc_jsp.java:48)
    at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:97)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:810)
    at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:332)
    at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:314)
    at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:264)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:810)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:252)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
    at org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:96)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
    at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:213)
    at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:178)
    at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:175)
    at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:74)
    at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:126)
    at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:105)
    at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:107)
    at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:148)
    at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:869)
    at org.apache.coyote.http11.Http11BaseProtocol$Http11ConnectionHandler.processConnection(Http11BaseProtocol.java:664)
    at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:527)
    at org.apache.tomcat.util.net.MasterSlaveWorkerThread.run(MasterSlaveWorkerThread.java:112)
    at java.lang.Thread.run(Unknown Source)
    12:00:56,843 ERROR [[jsp]] Servlet.service() for servlet jsp threw exception
    org.eclipse.swt.SWTException: Invalid thread access
    at org.eclipse.swt.SWT.error(SWT.java:3563)
    at org.eclipse.swt.SWT.error(SWT.java:3481)
    at org.eclipse.swt.SWT.error(SWT.java:3452)
    at org.eclipse.swt.widgets.Widget.error(Widget.java:432)
    at org.eclipse.swt.widgets.Shell.<init>(Shell.java:274)
    at org.eclipse.swt.widgets.Shell.<init>(Shell.java:265)
    at org.eclipse.swt.widgets.Shell.<init>(Shell.java:218)
    at org.eclipse.swt.widgets.Shell.<init>(Shell.java:156)
    at br.com.tryblob.view.WordSearchReplace.<init>(WordSearchReplace.java:36)
    at org.apache.jsp.replacedoc_jsp._jspService(replacedoc_jsp.java:48)
    at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:97)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:810)
    at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:332)
    at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:314)
    at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:264)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:810)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:252)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
    at org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:96)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
    at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:213)
    at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:178)
    at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:175)
    at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:74)
    at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:126)
    at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:105)
    at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:107)
    at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:148)
    at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:869)
    at org.apache.coyote.http11.Http11BaseProtocol$Http11ConnectionHandler.processConnection(Http11BaseProtocol.java:664)
    at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:527)
    at org.apache.tomcat.util.net.MasterSlaveWorkerThread.run(MasterSlaveWorkerThread.java:112)
    at java.lang.Thread.run(Unknown Source)
    ==================JAVA CLASS=====================
    import org.eclipse.swt.SWT;
    import org.eclipse.swt.SWTException;
    import org.eclipse.swt.internal.ole.win32.TYPEATTR;
    import org.eclipse.swt.ole.win32.OLE;
    import org.eclipse.swt.ole.win32.OleAutomation;
    import org.eclipse.swt.ole.win32.OleClientSite;
    import org.eclipse.swt.ole.win32.OleFrame;
    import org.eclipse.swt.ole.win32.OleFunctionDescription;
    import org.eclipse.swt.ole.win32.OlePropertyDescription;
    import org.eclipse.swt.ole.win32.OleParameterDescription;
    import org.eclipse.swt.widgets.Shell;
    import org.eclipse.swt.ole.win32.Variant;
    import java.io.File;
    import java.io.FileNotFoundException;
    import java.io.FileWriter;
    import java.io.BufferedWriter;
    import java.io.IOException;
    public class WordSearchReplace {
         private static final String PROG_ID = "Word.Application";
         private static final int WD_REPLACE_ALL = 2;
         private static final int WD_FIND_CONTINUE = 1;
         private Shell shell = null;
         private OleFrame frame = null;
         private OleClientSite wordSite = null;
         private OleAutomation wordAutomation = null;
         private OleAutomation activeDocumentAutomation = null;
         private boolean cleaned = false;
         * Create a new instance of the WordSearchReplace class.
         public WordSearchReplace() {
              this.shell = new Shell();
              this.frame = new OleFrame(this.shell, SWT.NONE);
              this.wordSite = new OleClientSite(this.frame, SWT.NONE, WordSearchReplace.PROG_ID);
         this.wordAutomation = new OleAutomation(this.wordSite);
         * Open an MS Word file. This is a file whose name ends with the extension
         * .doc or .doc and which conforms to the correct format.
         * Note; if it is possible to open the named file, an attempt is made
         * to cache an OleAutomation object referencing that file which will be
         * referred to in future as the active document. Most other methods
         * need to capture references to further OleAutomation(s) that have the
         * active document as their root.
         * @param fileName An instance of the String class that encapsulates the
         * path to and name of the file that is to be opened.
         * Note; the full path name must be supplied as Word
         * will be opening the file and no assumptions can
         * safely be made concerning the applications 'home'
         * folder.
         * @throws NullPointerException if a null value is passed to the fileName
         * parameter.
         * @throws FileNotFoundException if it is not possible to locate the
         * file.
         * @throws IllegalArgumentException if the name of the file does not end
         * with either the .dot or .doc extensions.
         * @throws SWTException if a problem occurs whilst invoking any of the OLE
         * methods.
         public void openFile(String fileName) throws SWTException,
         NullPointerException,
         FileNotFoundException,
         IllegalArgumentException {
              OleAutomation documentsAutomation = null;
              int[] id = null;
              Variant[] arguments = null;
              Variant invokeResult = null;
              try {
                   // Check the the file name is not null
                   if(fileName == null) {
                        throw new NullPointerException("Null value passed to " +
                             "fileName parameters of the openFile() method.");
                   // Check the the file names ends with '.dot' or '.doc'.
                   // Remember to include templates and docuemnts
                   if(!(fileName.endsWith(".doc")) && !(fileName.endsWith(".dot"))) {
                        throw new IllegalArgumentException(
                             "The filename must end with the extensions \'.doc\' or \'.dot\'");
                   // Check that the file exists
                   File fileToPrint = new File(fileName);
                   if(!(fileToPrint.exists())) {
                        throw new FileNotFoundException("The file " +
                        fileName +
                        "cannot be found.");
                   // From the application, get an automation for the Documents property
                   documentsAutomation = this.getChildAutomation(this.wordAutomation,
                   "Documents");
                   // Get the ID of the Open method
                   id = documentsAutomation.getIDsOfNames(new String[]{"Open"});
                   if(id == null) {
                        throw new SWTException("It was not possible to recover an " +
                        "identifer for the Open method in WordSearchReplace.openFile().");
                   // Build an array of parameters - holds just the file name
                   arguments = new Variant[1];
                   arguments[0] = new Variant(fileName);
                   // Invoke the Open method on the Documents property
                   invokeResult = documentsAutomation.invoke(id[0], arguments);
                   // If the call to invoke the open method failed, throw an SWTException
                   // to terminate processing.
                   if(invokeResult == null) {
                        throw new SWTException("An error occurred whilst invoking the " +
                             "Open method for the following file: " +
                             fileName +
                             " in WordSearchReplace.openFile().");
                   // If it was possible to open the document successfully, grab an
                   // automation object referencing the active document here.               
                   else {
                        this.activeDocumentAutomation = this.getChildAutomation(
                             this.wordAutomation, "ActiveDocument");
              finally {
                   // If the automation was instantiated then dispose of it to
                   // release resources. This OleAutomation was only required
                   // to open the file and can safely be released here.
                   if(documentsAutomation != null) {
                        documentsAutomation.dispose();
         * Save the currently open file - the active document.
         * @throws SWTException if a problem occurs whilst invoking any of the OLE
         * methods.
         public void save() throws SWTException {
              int[] id = null;
              Variant invokeResult = null;
              // From the automation for the ActiveDocument object, get an id for
              // the Save method
              id = this.activeDocumentAutomation.getIDsOfNames(new String[]{"Save"});
              // If it was not possible to recover the id of the Save
              // method, throw an exception to notify the user and terminate
              // processing.
              if(id == null) {
                   throw new SWTException("Unable to obtain an automation for " +
                        "the Save method in WordSearchReplace.save().");
              // Invoke the Save method and catch the value returned
              invokeResult = this.activeDocumentAutomation.invoke(id[0]);
              // If a null value was returned then the invocation of the
              // Save method failed. Throw an exception to notify the
              // user and terminate processing.
              if(invokeResult == null) {
                   throw new SWTException("A problem occurred invoking the " +
                        "Save method in WordSearchReplace.save().");
         * Save the active document using the name provided.
         * @param fileName Am instance of the String class encapsulating the name
         * for the file. Again, the path to and name of the file should
         * be supplied.
         * @throws NullPointerException if a null value is passed to the fileName
         * parameter.
         * @throws IllegalArgumentException if either an empty String is passed
         * to the fileName parameter or if the files name does not end
         * with one of the two permissible extensions - .dot and .doc
         public void saveAs(String fileName) throws SWTException,
         NullPointerException,
         IllegalArgumentException {
              int[] id = null;
              Variant[] arguments = null;
              Variant invokeResult = null;
              // If the fileName parameter is passed a null
              // value, throw an exception.
              if(fileName == null) {
                   throw new NullPointerException("A null value was passed to " +
                        "the fileName parameter of WordSearchReplace.saveAs().");
              // If the fileName parameter has been passed an empty String
              // then again throw an exception.
              if(fileName.length() == 0) {
                   throw new NullPointerException("An empty string was passed " +
                        "to the fileName parameter of WordSearchReplace.saveAs().");
              // Finally, make sure the file name ends in either
              // .doc or .dot.
              if((!fileName.endsWith(".dot")) && (!fileName.endsWith(".doc"))) {
                   throw new IllegalArgumentException("An illegal file name was " +
                        "passed to the fileName parameter of " +
                        "WordSearchReplace.saveAs(). The file name must " +
                        "end in \'.dot\' or \'.doc\'.");
              // From the automation for the ActiveDocument object, get an id for
              // the SaveAs method
              id = this.activeDocumentAutomation.getIDsOfNames(new String[]{"SaveAs"});
              // If it was not possible to recover the id of the SaveAs
              // method, throw an exception to notify the user and terminate
              // processing.
              if(id == null) {
                   throw new SWTException("Unable to obtain an automation for " +
                        "the SaveAs method in WordSearchReplace.saveAs().");
              // Build the array of arguments that will be passed to the invoke
              // method when the SaveAs method is invoked. In this case, this
              // array will contain a single member - a String object encapsulating
              // the path to and name of the output file.
              arguments = new Variant[1];
              arguments[0] = new Variant(fileName);
              // Invoke the SaveAs method and catch the value returned
              invokeResult = this.activeDocumentAutomation.invoke(id[0], arguments);
              // If a null value was returned then the invocation of the
              // PrintOut method failed. Throw an exception to notify the
              // user and terminate processing.
              if(invokeResult == null) {
                   throw new SWTException("A problem occurred invoking the " +
                        "SaveAs method in WordSearchReplace.saveAs().");
         * Mimics Words 'replace' functionality by searching the active
         * document for evey string of characters that matches the value passed to
         * the searchTerm parameter and replacing them with the string of
         * characters passed to the replacementTerm method.
         * It is possible to code a VBA macro within Word that will perfrom a serach
         * and replace. That code would look like the following;
         * <pre>
         *      Selection.Find.ClearFormatting
    *     Selection.Find.Replacement.ClearFormatting
    *     With Selection.Find
    *      .Text = "serach"
    *      .Replacement.Text = "search"
    *      .Forward = True
    *      .Wrap = wdFindContinue
    *      .Format = False
    *      .MatchCase = False
    *      .MatchWholeWord = False
    *      .MatchWildcards = False
    *      .MatchSoundsLike = False
    *      .MatchAllWordForms = False
    *     End With
    *     Selection.Find.Execute Replace:=wdReplaceAll
    * <pre>
    * and this method will 'automate' it.
         * @param searchTerm An instance of the String class that will encapsulate
         * the series of characters that should be replaced.
         * @param replacementTerm An instance of the String class that will
         * encapsulate the series of characters that should replace the
         * searchTerm.
         * @throws NullPointerException if a null value is passed to either the
         * searchTerm or replacementTerm methods.
         * @throws SWTException if a problem occurs when invoking any of the
         * OLE methods.
         public void replace(String searchTerm,
         String replacementTerm) throws SWTException,
         NullPointerException {
              OleAutomation selectionFindAutomation = null;
              OleAutomation childAutomation = null;
              Variant[] arguments = null;
              Variant invokeResult = null;
              int[] id = null;
              int[] namedArguments = null;
              boolean success = true;
              // Validate the searchTerm parameter and throw exception if
              // null value passed.
              if(searchTerm == null) {
                   throw new NullPointerException("Null value passed to " +
                             "searchTerm parameter of the replace() method.");
              // Validate the replacementTerm parameter and throw exception if
              // null value passed.
              if(replacementTerm == null) {
                   throw new NullPointerException("Null value passed to " +
                             "replacementTerm parameter of the replace() method.");
              // Most of the VBA instructions used to perform the search and
              // replace functionality and child automations of Selection.Find,
              // therefore, it is wise to cache that automation first.
              // From the application, get an automation for the Selection property
              childAutomation = this.getChildAutomation(this.wordAutomation,
                   "Selection");
              selectionFindAutomation = this.getChildAutomation(childAutomation,
              "Find");
              // Next, using the cached automation, invoke the 'ClearFormatting'
              // method, validate the returned value and invoke the method.
              // Selection.Find.ClearFormatting
              id = selectionFindAutomation.getIDsOfNames(new String[]{"ClearFormatting"});
              if(id == null) {
                   throw new SWTException("It is not possible to recover an identifier " +
                        "for the ClearFormatting method in WordSearchReplace.replace() " +
                        "when clearing the formatting for the search string.");
              invokeResult = selectionFindAutomation.invoke(id[0]);
              if(invokeResult == null) {
                   throw new SWTException("A problem occurred invoking the " +
                        "ClearFormatting method in WordSearchReplace.repace() " +
                        "when clearing formatting for the search string.");
              // Now, perform the same function but for the replacement string.
              // Selection.Find.Replacement.ClearFormatting
              childAutomation = this.getChildAutomation(selectionFindAutomation,
              "Replacement");
              id = childAutomation.getIDsOfNames(new String[]{"ClearFormatting"});
              if(id == null) {
                   throw new SWTException("It is not possible to recover an identifier " +
                        "for the ClearFormatting method in WordSearchReplace.replace() " +
                        "when clearing the formatting for the replacement string.");
              invokeResult = childAutomation.invoke(id[0]);
              if(invokeResult == null) {
                   throw new SWTException("A problem occurred invoking the " +
                        "ClearFormatting method in WordSearchReplace.repace() " +
                        "when clearing formatting for the replacement string.");
              // Firstly, set the search text.
              // .Text = "search term"
              arguments = new Variant[1];
              arguments[0] = new Variant(searchTerm);
              success = this.setPropertyValue(selectionFindAutomation, "Text", arguments);
              if(!success) {
                   throw new SWTException("A problem occurred setting the Text " +
                        "property for the search string in WordSearchReplace.replace().");
              // Next, the replacement text
              // .Replacement.Text = "replacement term"
              childAutomation = this.getChildAutomation(selectionFindAutomation,
              "Replacement");
              arguments[0] = new Variant(replacementTerm);
              success = this.setPropertyValue(childAutomation, "Text", arguments);
              if(!success) {
                   throw new SWTException("A problem occurred setting the Text property" +
                        " for the replacement string in WordSearchReplace.replace().");
              // Set the direction of the search - forward in this case.
              // .Forward = True
              arguments[0] = new Variant(true);
              success = this.setPropertyValue(selectionFindAutomation, "Forward", arguments);
              if(!success) {
                   throw new SWTException("A problem occurred setting the Forward " +
                        "property in WordSearchReplace.replace().");
              // Tell the search to wrap. Note the literal wdFindContinue relates to
              // a constant that is defined within Word. I have provided a static
              // final to replace it called WD_FIND_CONTINUE
              // .Wrap = wdFindContinue
              arguments[0] = new Variant(WordSearchReplace.WD_FIND_CONTINUE);
              success = this.setPropertyValue(selectionFindAutomation, "Wrap", arguments);
              if(!success) {
                   throw new SWTException("A problem occurred setting the Wrap " +
                        "property in WordSearchReplace.replace().");
              // Set the Format property to False.
              // .Format = False
              arguments[0] = new Variant(false);
              success = this.setPropertyValue(selectionFindAutomation, "Format", arguments);
              if(!success) {
                   throw new SWTException("A problem occurred setting the Format " +
                        "property in WordSearchReplace.replace().");
              // Set the MatchCase property to false.
              // .MatchCase = False
              arguments[0] = new Variant(false);
              success = this.setPropertyValue(selectionFindAutomation, "MatchCase", arguments);
              if(!success) {
                   throw new SWTException("A problem occurred setting the MatchCase " +
                        "property in WordSearchReplace.replace().");
              // Set the MatchWholeWord property to false.
              // .MatchWholeWord = False
              arguments[0] = new Variant(false);
              success = this.setPropertyValue(selectionFindAutomation, "MatchWholeWord", arguments);
              if(!success) {
                   throw new SWTException("A problem occurred setting the " +
                        "MatchWholeWord property in WordSearchReplace.replace().");
              // Set the MatchWildCards property to false.
              // .MatchWildcards = False
              arguments[0] = new Variant(false);
              success = this.setPropertyValue(selectionFindAutomation, "MatchWildCards", arguments);
              if(!success) {
                   throw new SWTException("A problem occurred setting the " +
                        "MatchWildCards property in WordSearchReplace.replace().");
              // Set the MatchSoundsLike property to false.
              // .MatchSoundsLike = False
              arguments[0] = new Variant(false);
              success = this.setPropertyValue(selectionFindAutomation, "MatchSoundsLike", arguments);
              if(!success) {
                   throw new SWTException("A problem occurred setting the " +
                        "MatchSoundsLike property in WordSearchReplace.replace().");
              // Set the MatchAllWordForms property to false.
              // .MatchAllWordForms = False
              arguments[0] = new Variant(false);
              success = this.setPropertyValue(selectionFindAutomation, "MatchAllWordForms", arguments);
              if(!success) {
                   throw new SWTException("A problem occurred setting the " +
                        "MatchAllWordForms property in WordSearchReplace.replace().");
              // Invoke the Execute command passing the correct value to the Replace
              // parameter. Again, wdReplaceAll is a constant that I have provided
              // a ststic final for called WD_REPLACE_ALL
              // Selection.Find.Execute Replace:=wdReplaceAll
              id = selectionFindAutomation.getIDsOfNames(new String[]{"Execute", "Replace"});
              if(id == null) {
                   throw new SWTException("It was not possible to recover an identifier " +
                        "for the Execute method in WordSearchReplace.replace().");
              arguments = new Variant[1];
              arguments[0] = new Variant(WordSearchReplace.WD_REPLACE_ALL);
              namedArguments = new int[1];
              namedArguments[0] = id[1];
              // There was some indication that the invokeNoReply method should
              // be used when making this call but no, invoke SEEMS to work well
              //selectionFindAutomation.invokeNoReply(id[0], arguments, namedArguments);
              invokeResult = selectionFindAutomation.invoke(id[0], arguments, namedArguments);
              if(invokeResult == null) {
                   throw new SWTException("A problem occurred trying to invoke the " +
                   "Execute method in WordSearchReplace.replace().");
         * Close the active document.
         * @throws SWTException if a problem is encountered invoking any of the
         * OLE methods.
         public void closeFile() throws SWTException {
              int[] id = null;
              Variant[] arguments = null;
              Variant invokeResult = null;
              try {
                   // From the OleAutomation referencing the active document, recover
                   // the id of the Close method.
                   id = this.activeDocumentAutomation.getIDsOfNames(new String[]{"Close"});
                   // If it was not possible to recover the id of the Close
                   // method then throw an exception to notify the user and
                   // terminate processing.
                   if(id == null) {
                        throw new SWTException("It was not possible to recover an " +
                             "identifier for the Close method in " +
                             "WordSearchReplace.closeFile().");
                   // Invoke the Close method on the ActiveDocument automation
                   invokeResult = this.activeDocumentAutomation.invoke(id[0]);
                   // If the invocation of the Close method failed, throw an
                   // exception to notify the user and terminate processing.
                   if(invokeResult == null) {
                        throw new SWTException(
                             "An error occurred invoking the Close method in " +
                             "WordSearchReplace.closeFile().");
              finally {
                   if(this.activeDocumentAutomation != null) {
                        this.activeDocumentAutomation.dispose();
         * Release resources.
         public void dispose() throws SWTException {
              try {
                   // Set the cleaned flag to true. This prevents the method from
                   // running again if it is called from the finalize() method
                   this.cleaned = true;
                   // From the word automation, recover the id of the Quit method
                   int[] id = this.wordAutomation.getIDsOfNames(new String[]{"Quit"});
                   // If the id of the Quit method cannot be recovered
                   // throw an exception - not much good really though.
                   if(id == null) {
                        throw new SWTException("Unable to obtain an id for the Quit " +
                             "property in WordSearchReplace.dispose().");
                   // Invoke Quit
              Variant result = this.wordAutomation.invoke(id[0]);
              // If an error occurs during the invocation, throw an exception.
              // Again though that exception is of limited value.
              if(result == null) {
                   throw new SWTException("A problem occurred trying to invoke the " +
                        "Quit method in WordSearchReplace.dispose().");
         finally {
              // Finally, dispose of the word application automation.
              this.wordAutomation.dispose();
         * The finalize() method has been over-ridden to ensure that resources
         * are correctly released if a WordSearchReplace object is created but
         * not disposed of properly before it becomes eligible for garbage
         * collection. The cleaned flag is used as acheck to ensure that the
         * dispose() method cannot be called more than once.
         public void finalize() throws Throwable {
              if(!this.cleaned) {
                   this.dispose();
         * Creates and returns a 'child' OleAutomation object. The object model
         * employed by Word, Excel and the like, arrange objects, methods and
         * properties hierarchically. To invoke a method, it is often necessary
         * to iterate through this hierarchy from parent to child and this method
         * supports that process.
         * @param automation An OleAutomation object that references the parent
         * automation.
         * @param childName An instance of the String class that encapsulates the
         * name of the child automation.
         * @throws SWTException if a problem is encountered invoking one or
         * other of the OLE methods.
         private OleAutomation getChildAutomation(OleAutomation automation,
         String childName) throws SWTException {
              // Try to recove the unique identifier for the child automation
              int[] id = automation.getIDsOfNames(new String[]{childName});
              // If the identifier cannot be found then throw an exception to
              // terminate processing.           
              if (id == null) {
                   throw new SWTException(
                        "A problem occurred trying to obtain and id for: " +
                   childName +
                   "in the getC

    When you call it the first time, it new Shell() constructs a new Display for you (the default).
    The second time, it gets the default display, but you are in a different Thread now. Since you have to create your widgets in the UI thread, it gives you that error.
    To run code in the UI thread, Display provides two methods:
    display.syncexec(..)and
    display.asyncexec(...)see
    http://help.eclipse.org/help32/index.jsp?topic=/org.eclipse.platform.doc.isv/guide/swt_threading.htm
    for more details.

  • Searching for a good file manager

    I'm searching for a good file manager. Konqueror 3.5 is quite good, dolphin 4.1 and konqueror 4.1 are not. Since konqueror 3.5 is going to die due to lack of support in the future, I kind of need to find a new good file manager...
    Do there exist file managers with the following features?
    Many of these features are things I thought were quite logical to be in a file manager, but seem to be missing in most "modern" ones...
    -independent of any desktop (gnome or KDE), just a standalone program
    -preferably not being both a web browser and file manager in once, at least not in an annoying way. Konqueror 3.5 shows that being that combination is possible without being annoying.
    -ability to have a tree view of the folders on one side and list view showing the files and subfolders of the folder currently selected in the tree on the other side
    -detailed list view showing at least filename, type, date and size, and the ability to sort according to any of these properties
    -a non-detailed view showing image contents would also be nice, to browse folders of photos or other images
    -ability to open files in certain programs if you doubleclick the file, NOT open it by singleclicking, singleclicking may only select it
    -ability to select multiple files by dragging box around files or using keys like "ctrl" and "shift"
    -ability to do "open terminal here" or type terminal commands in the current open directory
    -must have ability to drag files from one folder to another, from list view to tree view and vica versa, to move or copy them
    -and must have ability to use "ctrl+c" and "ctrl+v" to copy files and foldes from here to there
    -multiple tabs is a huge plus
    -favorites (to local folder paths) is also a huge plus
    -preview of files when hovering the mouse over them is nice
    -must have ability to zip and unzip (or other compression formats) folders by just right clicking them and choosing a zip/unzip command there
    -in addition to that, must also have ability to browse through a zip file as you would through a normal directory, and drag files from the insides of the zip file to the tree view to automatically unzip those files there, and of course "ctrl+c"/"ctrl+v" should also work to copy a file from the inside of the zip file, to some other folder on your disk
    -no horizontal autoscrolling in the tree view, that is an invention straight from the abyss...

    I know exactly how you feel about KDE 4 vs. 3 -- Konqueror was the best part of KDE for me (pretty much the only part I ever used, actually; my window manager is a slightly modified version of WMII and I generally loathe "desktop environments"). KDE 4 ruined it, completely and utterly.
    I submitted about 20 different bug reports about Konqeuror 4, mostly features that they'd deleted or mangled; some of them are starting to be addressed now. I don't think they'll ever fix the speed issues though, because those are dependent on the underlying KDE 4 libraries as far as I can tell -- it's as if KDE 4 were purposely and deliberately designed to be slower than KDE 3. Even if they fix all of its deficiencies, that'll probably keep me from using it...
    Right now there's KDEmod, which will hopefully maintain its KDE 3 branch for a while longer. It's starting to show some problems, though; I haven't been able to get kdemod konqueror 3 to work fully out of the box (the settings pages are all blank). On my main machine, I somehow managed to hack together some of the KDEmod3 packages so that I have a functional konqueror 3 running alongside the Arch repository's version of KDE4. I'm afraid to pacman -Syu now, though, because it will probably break horribly :P
    I don't remember exactly how I got konqueror 3 going like that, as I did it in my initial fit of rage after I did the pacman -Syu that got me KDE4 (a decision I have regretted ever since), but it was something like this:
    1. move /opt to /opt.kde4
    2. make a new /opt
    3. download several KDE 3 packages from the KDEmod3 repositories manually
    4. extract those packages into the new /opt with tar -xzf (NOT pacman!)
    5. try /opt/kde/bin/konqueror
    6. read reams of error messages about missing libraries, segfaults, etc.
    7. try to supply the missing libraries by downloading other kdemod3 packages and manually extracting them
    8. goto 5
    Then, when everything worked (sort of), I renamed some stuff so that 'konqueror' is konqueror 4 (I think having it konqueror 3 broke something else, but I don't remember what), and konqueror 3 is called 'k3nqueror'.
    If KDEmod3 ever goes away and there's no other good replacement file manager by then, I'll probably take the source code of KDE3 and try to make a standalone version of konqueror out of it. (Which will probably be quite a project because of how interdependent all the KDE components are.)
    Some features I "need" in a file manager, besides the ones you mentioned:
    - Konqueror's tree view (where you can expand folder branches in the file list)
    - Infinite view splitting -- I frequently have my konqueror windows split into 4, sometimes as many as 6 or 7 view panes. Very useful for sorting out files.
    - Selection rectangles are sensitive only over files -- I find full-row-select really annoying, because there are no guaranteed "blank" areas that you can click on to clear a selection. I also use this behaviour to grab long-named files that are interspersed with short ones, because they hilight first when the rectangle touches them (you wouldn't think this very useful, but surprisingly often you do want to do something to all the long-named files...)
    - Right-clicking on a folder and clicking "Paste" pastes into that folder, not the current one -- you'd be amazed at how many file managers get this wrong. I shouldn't have to cd into a folder just to paste some files there.

  • How to use search/find function in a whole book?

    Hi,
    New to indesign... working on a book file which comprises 25 chapters.
    I'd like to do a final proof to ensure all double spaces have gone, all quote marks are right etc
    Instead of opening each chapter and using "search/find" through each chapter, can i tell the "search/find" function through the whole book?
    Appreciate any feedback
    Thanks heaps

    Apparently Adobe thought that would be more appreciated than a book-wide Search/Replace.
    You can read all about CS5's new features, and their selection procedure, on http://indesignsecrets.com/michael-ninness-answers-indesign-cs5-critics.php. The "Book" feature doesn't even get mentioned under "Sorry, we didn't change that at all." Also make sure to read the comments -- it seems lots of people really want more book features.
    If you're one of them (so it seems), you might want to pay a visit to https://www.adobe.com/cfusion/mmform/index.cfm?name=wishform

Maybe you are looking for

  • How to add default values when adding custom component to design view?

    I have a set of custom components (usually) extending Spark components. But when adding our custom component onto design view, how can I define defult values (in AS3). For example, s:Button has default label = 'Button' when added to application, or m

  • In search of Oracle 10g / Sun 86*64 Tape device 3rd party software:

    What secure tape backup software (i.e. OSB not supported by Sun 86*64) do you recommend for this configuration: Clustered Database, ASM Database: Oracle 10.2.0.1 (going to 10.2.0.2) clustered database. Operating System: SUN Version and Release 14:35:

  • Simsession short dump when calling BAPI

    Hello, I have created a macro in Demand Planning that calls BAPI_APO_AVAILABILITY_CHECK. When running this is SE37 or SE38, everything works fine. But when calling this from //SDP94 I got a shortdump, because the BAPI wanted to create a simsession, b

  • Where Can I download oracle report builder 10.1.2

    Hi All, Can you help to give the path to downlaod the report builder 10.1.2 . Thanks, Vignesh

  • Solaris on Gigabyte motherboard

    Hi All!! after futile trials to install solaris on my dell laptop i tried installing on my desktop-customer built new HD it all installed fine.....but my mouse acts weird...i cant click the right things in the right place....may be i need mouse drive