/**
 * Copyright (c) 2002-2013 "Neo Technology,"
 * Network Engine for Objects in Lund AB [http://neotechnology.com]
 *
 * This file is part of Neo4j.
 *
 * Neo4j is free software: you can redistribute it and/or modify
 * it under the terms of the GNU Affero General Public License as
 * published by the Free Software Foundation, either version 3 of the
 * License, or (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU Affero General Public License for more details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program. If not, see <http://www.gnu.org/licenses/>.
 */
package org.neo4j.desktop.config.windows;

import java.io.File;
import java.io.IOException;
import java.net.URISyntaxException;

import org.neo4j.desktop.config.portable.PortableEnvironment;

import static java.lang.Runtime.getRuntime;

class WindowsEnvironment extends PortableEnvironment
{
    @Override
    public void openBrowser( String link ) throws IOException, URISyntaxException
    {
        if ( isPortableBrowseSupported() )
        {
            portableBrowse( link );
            return;
        }

        throw new UnsupportedOperationException();
    }

    @Override
    public void editFile( File file ) throws IOException
    {
        if ( isPortableEditFileSupported() )
        {
            try
            {
                portableEditFile( file );
                return;
            }
            catch ( IOException e )
            {
                e.printStackTrace( System.out );
            }
        }

        windowsEditFile( file );
    }

    private void windowsEditFile( File file ) throws IOException
    {
        getRuntime().exec( new String[]{"rundll32", "url.dll,FileProtocolHandler", file.getAbsolutePath()} );
    }

    @Override
    public void openDirectory( File directory ) throws IOException
    {
        if ( isPortableOpenSupported() )
        {
            try
            {
                portableOpen( directory );
                return;
            }
            catch ( IOException e )
            {
                e.printStackTrace( System.out );
            }
        }

        windowsOpenDirectory( directory );
    }

    private void windowsOpenDirectory( File directory ) throws IOException
    {
        getRuntime().exec( new String[] { "explorer", directory.getAbsolutePath() } );
    }
}

@@ -1739,33 +1739,32 @@
     %7D%0A        %7D%0A
-%0A
         windowsE
@@ -1870,106 +1870,102 @@
     
-getRuntime().exec( new String%5B%5D%7B%22rundll32%22, %22url.dll,FileProtocolHandler%22, file.getAbsolutePath()%7D
+String%5B%5D cmdarray = %7B %22notepad%22, file.getAbsolutePath() %7D;%0A        getRuntime().exec( cmdarray
  );%0A

Edit files with Notepad if Desktop.edit fails