Add file contents using drag drop method

I want to add file contents to a text view by drag drop method. How i can do that in cocoa using objective c? Can anybody help me. I am using following code in my appCotroller file to do the same but can't get the desired out put. Insted of getting file contents, i m getting the file URL (Path) in the text view.

shaktirsg wrote:
As you said i have to open that file in my performDragOperation function, I want to know where to write this function. bcoz i have written this function in my appCotroller class but that code does'n get executed. Can you help me on this.
It is very hard to debug code I haven't seen. If you are getting the URL in your text view, you must be handling the drag operation correctly. Instead of putting the pasteboard data into the text view, get the file's contents and put that into the text view.
Also can you give me a sample code on how to open files in coccoa, how to read the contents of that file?
Look at NSString's "stringWithContentsOfFile:encoding:error:"

Similar Messages

  • How to Rearrange components using Drag Drop functionality

    Hi,
    Is it possible to re-arrange the components inside the form using drag drop functionality in RCF?
    There are 3/4 section headers in my screen, user can re-arrange them.
    But as per the RCF document it says, "Drag Drop functionality allows users to drag the value of one component and drop it on to another". It dosent say any thing about component drag-drop.

    Hi,
    there is a componentDragSource element that you use for this. However, persisting the change of location is not handled automatically. I didn't try this, but I assume that using the component drag option gives you access to the UI component itself so you can nest it in another container
    Frank
    Ps.: the drag event always givey you access to the component. This componentDragSource however shows the component when dragging, which is a slightly better indicator if you plan to re-arrange items

  • Can't use drag&drop

    Hello, I'm using MacBook Pro (retina, 15", late 2013, 2,3 GHz Intel core i7) and after using for a while happened smh strange. I can't use drag&drop, so I can't select the object and drag it. What is wrong?

    Hello!
    I wonder, does the issue persist even after a simple restart of OS X?
    If so, please start Disk Utility (it's in your Applications>Utilities folder), click on your harddrive and select [repair disk permissions]

  • How to print a text file contents using java.

    Using Input and Output streams I can add and retrive the contents to/from text file. But how to send this file contents to the printer or how to print the file.

    Example from my code:
       private void printErrorReport()
          PrintJob pjob = getToolkit().getPrintJob(m_frame,null,null);
          if (pjob != null) {
            Graphics pg = pjob.getGraphics();
            if (pg != null) {
              String s = detailsArea.getText();
              printLongString (pjob, pg, s);
              pg.dispose();
            pjob.end();
    // Utility method needed
       void printLongString (PrintJob pjob, Graphics pg, String s) {
         int pageNum = 1;
         int linesForThisPage = 0;
         int linesForThisJob = 0;
         // Note: String is immutable so won't change while printing.
         if (!(pg instanceof PrintGraphics)) {
           throw new IllegalArgumentException ("Graphics context not PrintGraphics");
         StringReader sr = new StringReader (s);
         LineNumberReader lnr = new LineNumberReader (sr);
         String nextLine = "       ";
         int pageHeight = pjob.getPageDimension().height;
         pageHeight -= 20;
         Font helv = new Font("Arial", Font.PLAIN, 12);
         //have to set the font to get any output
         pg.setFont (helv);
         FontMetrics fm = pg.getFontMetrics(helv);
         int fontHeight = fm.getHeight();
         int fontDescent = fm.getDescent();
         int curHeight = 0;
         try {
           do {
             nextLine = lnr.readLine();
             if (nextLine != null) {
               if ((curHeight + fontHeight) > pageHeight) {
                 // New Page
                 System.out.println ("" + linesForThisPage + " lines printed for page " + pageNum);
                 pageNum++;
                 linesForThisPage = 0;
                 pg.dispose();
                 pg = pjob.getGraphics();
                 if (pg != null) {
                   pg.setFont (helv);
                 curHeight = 0;
               curHeight += fontHeight;
               if (pg != null) {
                 pg.drawString (nextLine, 0, curHeight - fontDescent);
                 linesForThisPage++;
                 linesForThisJob++;
               } else {
                 System.out.println ("pg null");
           } while (nextLine != null);
         } catch (EOFException eof) {
           // Fine, ignore
         } catch (Throwable t) { // Anything else
           t.printStackTrace();
         System.out.println ("" + linesForThisPage + " lines printed for page " + pageNum);
         System.out.println ("pages printed: " + pageNum);
         System.out.println ("total lines printed: " + linesForThisJob);
         }

  • .avi files and subtitle drag&drop

    Is there any video player that can play .avi files and also support drag&drop subtitles? I tried Perian with Quick time and now it plays .avi files perfectly. However still can't drag the subtitles to Quicktime screen. Also I tried Miro and VLC Player. They both lack of 'drag&drop subtitle' function.
    I'm new to mac, only 3 days. Maybe there is a trick to do that drag&drop thing. Any help?

    use Mplayer from appstore and its free..:)

  • Add 3D Content using script

    Is there a way to script the addition of a 3D model to a pdf using the 3D tool "add 3D content".
    I am trying to semi-automate the addition of 3D models as follows
    User opens existing pdf form (template)
    User starts a script using a button
    Button code selects existing 3D model and brings up the Edit 3D content or add 3D content
    User selects model.
    I guess I don't see the API's for the 3D (model tool) in the reference, only the 3D annotations

    Alastair,
    Javascript intentionally has no File I/O. This is for security purposes. If you want to control the App externally, you can actually do this just fine using Windows Scripting Host and JScript or VBScript. I do this for automation testing all the time. You must create the "File Sytem Object" and "WScript.Shell" in JScript, and then can control Acrobat (or any other App) extensively using "SendKeys".
    This is all probably a bit much, but I was trying to give you a workaround if you reeeeeally wanted to make this happen automatically!

  • Reading file content using Javascript

    Hi Friends,
    is it possibel to read the contents of the child window opened from a javascript.for example am opening a window using Window.open function in javascript, after opening the window can i read the contents ?If so how can anyone help in this.
    Thanks
    Vishy

    Below is the code of my normal java program which works fine.
    try {
    // File destFile = new File("./SourceFiles/savedFile.txt");
    File destFile = new File("./SourceFiles/", "savedFile.txt");
    BufferedWriter writer = new BufferedWriter(new FileWriter(destFile));
    writer.write("TESTing File Save");
    writer.flush();
    System.out.println("SAVED!!");
    } catch ( IOException e ) {
    e.printStackTrace();
    Structure of this project is
    Samples
    |SaveSample
    |SaveSample.java
    |SourceFiles
    |savedFile.txt
    I have implemented similar code in my servlet too. But this doesnt save the content to the HTML file.
    protected void doPost(HttpServletRequest request,
                   HttpServletResponse response) throws ServletException, IOException {
              action = request.getParameter("action");
              try {
    File destFile = new File("./SourceFiles/", "savedFile.html");
    BufferedWriter writer = new BufferedWriter(new FileWriter(destFile));
    writer.write(action);
    writer.flush();
    System.out.println("SAVED!!");
    } catch ( IOException e ) {
    e.printStackTrace();
    Im getting FileNotFound Exception
    java.io.FileNotFoundException: .\SourceFiles\savedFile.html (The system cannot find the path specified)
         at java.io.FileOutputStream.open(Native Method)
         at java.io.FileOutputStream.<init>(Unknown Source)
         at java.io.FileOutputStream.<init>(Unknown Source)
         at java.io.FileWriter.<init>(Unknown Source)
         at savepackage.SaveContent.doPost(SaveContent.java:81)
    Edited by: 849224 on Apr 5, 2011 4:17 AM

  • Permanent list of duplicates using drag & drop with iPhoto 11

    Every time I drag and drop a photo into iPhoto 11 from a website or other source, I'm asked if I want to also add every other photo I've ever dragged and dropped in. I can opt not to import duplicates, but is there a way to clear out or avoid this ever-growing list?

    Go to your Pictures Folder and find the iPhoto Library there. Right (or Control-) Click on the icon and select 'Show Package Contents'. A finder window will open with the Library exposed.
    Look there for a Folder called 'Import' or 'Importing'.
    Drag it to the Desktop. *Make no other changes*.
    Start iPhoto. Does that help?
    If it does then look inside that folder on your desktop. Does it contain anything you want? If not you can trash the folder.

  • How to save a video file which uses the setCodecChain method on its video t

    hi! i really need your help please. i got the Code for RotationEffect and i would like to know how to save it to a file instead of playing it simultaneously in a player:
    Here is the code: Plz Help me!!! am doing my final year project
    import java.awt.*;
    import java.awt.event.*;
    import javax.media.*;
    import javax.media.control.TrackControl;
    import javax.media.Format;
    import javax.media.format.*;
    * Sample program to test the RotationEffect.
    public class TestEffect extends Frame implements ControllerListener {
    Processor p;
    Object waitSync = new Object();
    boolean stateTransitionOK = true;
    public TestEffect() {
         super("Test RotationEffect");
    * Given a media locator, create a processor and use that processor
    * as a player to playback the media.
    * During the processor's Configured state, the RotationEffect is
    * inserted into the video track.
    * Much of the code is just standard code to present media in JMF.
    public boolean open(MediaLocator ml) {
         try {
         p = Manager.createProcessor(ml);
         } catch (Exception e) {
         System.err.println("Failed to create a processor from the given url: " + e);
         return false;
         p.addControllerListener(this);
         // Put the Processor into configured state.
         p.configure();
         if (!waitForState(p.Configured)) {
         System.err.println("Failed to configure the processor.");
         return false;
         // So I can use it as a player.
         p.setContentDescriptor(null);
         // Obtain the track controls.
         TrackControl tc[] = p.getTrackControls();
         if (tc == null) {
         System.err.println("Failed to obtain track controls from the processor.");
         return false;
         // Search for the track control for the video track.
         TrackControl videoTrack = null;
         for (int i = 0; i < tc.length; i++) {
         if (tc.getFormat() instanceof VideoFormat) {
              videoTrack = tc[i];
              break;
         if (videoTrack == null) {
         System.err.println("The input media does not contain a video track.");
         return false;
         System.err.println("Video format: " + videoTrack.getFormat());
         // Instantiate and set the frame access codec to the data flow path.
         try {
         Codec codec[] = { new RotationEffect() };
         videoTrack.setCodecChain(codec);
         } catch (UnsupportedPlugInException e) {
         System.err.println("The processor does not support effects.");
         // Realize the processor.
         p.prefetch();
         if (!waitForState(p.Prefetched)) {
         System.err.println("Failed to realize the processor.");
         return false;
         // Display the visual & control component if there's one.
         setLayout(new BorderLayout());
         Component cc;
         Component vc;
         if ((vc = p.getVisualComponent()) != null) {
         add("Center", vc);
         if ((cc = p.getControlPanelComponent()) != null) {
         add("South", cc);
         // Start the processor.
         p.start();
         setVisible(true);
         addWindowListener(new WindowAdapter() {
         public void windowClosing(WindowEvent we) {
              p.close();
              System.exit(0);
         return true;
    public void addNotify() {
         super.addNotify();
         pack();
    * Block until the processor has transitioned to the given state.
    * Return false if the transition failed.
    boolean waitForState(int state) {
         synchronized (waitSync) {
         try {
              while (p.getState() != state && stateTransitionOK)
              waitSync.wait();
         } catch (Exception e) {}
         return stateTransitionOK;
    * Controller Listener.
    public void controllerUpdate(ControllerEvent evt) {
         if (evt instanceof ConfigureCompleteEvent ||
         evt instanceof RealizeCompleteEvent ||
         evt instanceof PrefetchCompleteEvent) {
         synchronized (waitSync) {
              stateTransitionOK = true;
              waitSync.notifyAll();
         } else if (evt instanceof ResourceUnavailableEvent) {
         synchronized (waitSync) {
              stateTransitionOK = false;
              waitSync.notifyAll();
         } else if (evt instanceof EndOfMediaEvent) {
         p.close();
         System.exit(0);
    * Main program
    public static void main(String [] args) {
         if (args.length == 0) {
         prUsage();
         System.exit(0);
         String url = args[0];
         if (url.indexOf(":") < 0) {
         prUsage();
         System.exit(0);
         MediaLocator ml;
         if ((ml = new MediaLocator(url)) == null) {
         System.err.println("Cannot build media locator from: " + url);
         System.exit(0);
         TestEffect fa = new TestEffect();
         if (!fa.open(ml))
         System.exit(0);
    static void prUsage() {
         System.err.println("Usage: java TestEffect <url>");

    Can you please send me Your codec class and guide me the way you use it .. i am trying to apply some filters on the movie before presenting. Any help would be appreciated.

  • File renaming with drag & drop import

    I want to import images on disk by dragging to projects to avoid the painfully slow import dialog animation, but I also want to rename masters on import. Is there a way to do this?

    Ah
    I think it is actually an Apple App switcher thing.
    So if the finder window does noy cover the After Effects Project window, it works, but if you have to use the app switcher, sometimes it works and sometimes it doesn't.
    I don't think it is a file type issue, so much as a live application issue, or maybe GPU related.
    It's a weird thing, not that important, but it does limit where you can and can't drag from.
    Tris

  • Using drag/drop to build data grid rows from multiple lists ?

    Hi,
    I have implemented some simple drag and drop between grids and lists, including images.
    What I need to do now is quite a bit more complex:
    Create rows in a data grid by dragging and dropping from multiple lists. That is, for a given
    row, column 1 receives data from list A and rows in column 2 - 5 receive data from List B
    I haven't found any examples that do this and my initial hacks haven't been successful.
    If you have any suggestions, they would be most appreciated !!!
    Thanks !  

    This does the trick...
    For my destination grid
    protected function dg_dragDropHandler(e:DragEvent):void
    // Dynamically add columns to the grid by dragging them from the new column list
                    if (e.dragInitiator["id"] == "lNewColumn")
                        e.preventDefault();    // handle this manually
                        var Id:Number;
                        var Name:String;
                        var numCols:int = e.dragInitiator["selectedItems"]["length"] as int;
                        for (var i:int=0; i < numCols; i++)
                            Id = e.dragInitiator["selectedItems"][i]["id"];
                            Name = e.dragInitiator["selectedItems"][i]["Name"];
                            addGridColumn(Id, Name);
    private function addGridColumn( Id:Number, Name:String ):void
                    var dgc:DataGridColumn;
                    var cols:Array = dg.columns;
                // not a duplicate column
                        dgc = new DataGridColumn(Name);
                        dgc.width=150;   
                        dgc.headerWordWrap = true;
                        dgc.itemRenderer=new ClassFactory(MyLovelyItemRenderer);    // unlike mxml, must explicitly cast
                        dgc.width=156;
                        dgc.headerText = Name + "\n Message";
                        dgc.dataField="messageId_" + Id.toString();    // allows split on '_' later to get Id
                        dgc.setStyle("textAlign","center");
                        cols.push(dgc);
                        dg.columns = cols;

  • Cant add files and use itunes at the same time?

    I am totally confused as to why Itunes is Frozen when im adding files. I usually manually add my music to itunes myself. I figured why not take advantage and just have it do it for me. Now i cant play or pause the music as its doing this. The main problem is that the folder of music that i added, has all my itunes files on that drive in that folder. Is it going to add everything i have twice now? its telling me new versions of apps are available. I have 600+ apps. Im starting to realise that there is no work around for this. perhaps this belongs in a suggestion thread. sorry for ranting. delete this post its looking like i have to force itunes closed and ruin everything that i have organised so i dont have to tell itunes 600 times that i dont want to find the new version of an app. I've already been fooled into recrediting all my downloads because Everyone wanted to play stupid on the phone. GOD HELP ME!

    Say i finish clicing x 600 times. Is there a way to stop the music after it resumes searching my 111 gb of music. i dont want to play the same cd the whole time.

  • Why '\' cannot be recognized in the cofigurati​on file content using read key vi

    Thanks.
    Solved!
    Go to Solution.

    turbot wrote:
    I use default, but replaced by mass code differently each time.
    Do you mean replaced by LabVIEW? If so, the Write Key function will automatically adapt to the data type you wire to the value terminal. Write Key is polymorphic, and does not display the 'Write Raw String? (F)' option unless you right click on the function and switch from automatic to string.
    I've attached a VI (LabVIEW 7.0) that shows examples of different ways to write and read a path to an INI.
    Open the INI created by this VI and compare the ways the data is written and read from the file...
    [Backslash]
    PathAsString="C:\\Documents and Settings\\pbrooks\\Desktop\\Escaped Backslashes.ini"
    PathAsPath="/C/Documents and Settings/pbrooks/Desktop/Escaped Backslashes.ini"
    PathAsRawString="C:\Documents and Settings\pbrooks\Desktop\Escaped Backslashes.ini"
    Message Edited by Phillip Brooks on 04-16-2009 07:47 AM
    Now is the right time to use %^<%Y-%m-%dT%H:%M:%S%3uZ>T
    If you don't hate time zones, you're not a real programmer.
    "You are what you don't automate"
    Inplaceness is synonymous with insidiousness
    Attachments:
    Escaped Backslashes.vi ‏68 KB

  • IC Agent mails attachment - Drag & Drop the file from local/desktop into mailform

    Dear Gurus,
    Please help me regarding the following it's urgent please!
    We have implemented the Interaction Center, in that we have one requirement, where uses/agents wants to attach/upload the file using drag & drop (mouse) method. The standard process is there will be an attachment block where we have button called browse, using this we can attache a file. Please suggest me is there any standard option/configuration to do this, if no standard way at least guide me how to achieve this using technical expertise.
    Thank you very much and Regards,
    Niranjan

    Hi Niranjan,
    Up to my understanding, SAP is working on this requirement of bringing the drag and drop upload functionality. You can find more information in the below link.
    You Asked for it, SAP Delivers: Twenty-Four (24) Cool New CRM Enhancements!
    Regards,
    karthi M R.

  • Bridge CS5 Windows crashes when I command/move or drag/drop files internally

    Bridge CS5 crashes with a Microsoft "report error" dialog whenever I drag images from one folder to another inside of Bridge, or use the right-click "Move To . . ." mouse command.  After months of successful use of the Bridge CS5, this behavior suddenly began.  Unfortunately, I can't now remember whether I did anything to my Windows environment at that time.  Bridge does not have trouble with dragging or command/moving files into Photoshop, but dragging image files (jpg) from a search screen or the Windows Explorer can also end in a crash.
    I'm running Windows XP SP3 32-bit on a 4-processor machine with adequate ram and lots of hard drive/scratch drive.  I deinstalled every trace of Bridge and reinstalled the upgrade 4.0.2.1, which makes me up to date. Working with Adobe Support I also cleared and uninstalled, and then reinstalled Photoshop, Bridge, etc. to fix some other problems.
    I have experimented with purging the Bridge cache for individual folders I was dragging from and to, but didn't purge all caches.  Typically, the crash appears a few seconds after dragging/moving a file - continuosly sucking-me into thinking things are at last repaired.  On occasion images are lost - i.e. really destroyed, or dropped into some limbo somewhere.
    I'd be truly grateful for any ideas to try, no matter how extensive or simple.
    Thanks!

    Hi Robert,
    I'm a developer from Br team. Thanks for reporting Br. problems.
    It seems like a memory issue. Please try this to help us identify the root cause:
    1. Disable all startup scripts (Edit->Preferences->Startup Scripts->Disable All), then restart Br.
    2. When Br is running, kill "SwitchBoard" process in task manager.
    3. When do Copy&Move operations, don't use Drag&Drop, try to use "Move To / Copy To" menu. (A known issue of Bridge, should be fixed in later versions)
    Does the crash still happens?
    Thanks very much!

Maybe you are looking for

  • File and Transaction Parity in PI 7.1

    Hello, We are currently designing our file and transaction Parity architechture for SAP PI 7.1. Could you please let me know where can I start on it. Does PI offers any out of the box parity services and any kind on documentation on it. Thank you.

  • How can I create packages procedure & function in user-define Library

    hi. i am already created packages procedure & function in database and use so on. now i would like to create these in library file. please anyone give me example of any procedure or function to store in library. thanks Ali

  • How to read attributes in to datagrid?

    hi i have one doubt in the datagrid we have header text but if we create dynamic datagrid and for (eg) <root> <data> <time datas="Hello"> <john  second="Karthikkkkkkkkk"></john> </time> </data> </root> if we want o make "datas" as header text what ca

  • Lightroom Mobile is only in trial mode

    I am subscriber to a single application for Adobe CC - Adobe Photoshop CC I have my own full payd version of Lightroom 5.5 But my Lightroom Mobile Plugin is only it Tial mode. Am I not quafified for a full working Lightroom Mobile Plugin. Any help wi

  • Comment effacer le contenu de mon macbookair ?

    comment effacer le contenu de mon macbookair ?