/*
 * Ema.java
 *
 * Created 2/22/ 2006
 */

package xal.app.ema;

import javax.swing.*;
import javax.swing.event.*;
import java.awt.event.*;
import java.net.*;

import xal.extension.application.*;
import xal.extension.application.smf.*;

/**
 * An application to perform automatically setting SCL cavities.
 * @author  jdg
 */
public class Ema extends ApplicationAdaptor {
    // --------- Document management -------------------------------------------
    
    /**
     * Returns the text file suffixes of files this application can open.
     * @return Suffixes of readable files
     */
    public String[] readableDocumentTypes() {
        return new String[0];
    }
    
    /**
     * Returns the text file suffixes of files this application can write.
     * @return Suffixes of writable files
     */
    public String[] writableDocumentTypes() {
        return new String[0];
    }
    
    
    /**
     * Implement this method to return an instance of my custom document.
     * @return An instance of my custom document.
     */
    public XalDocument newEmptyDocument() {
        return new EmaDocument();
    }
    
    
    /**
     * Implement this method to return an instance of my custom document 
     * corresponding to the specified URL.
     * @param url The URL of the file to open.
     * @return An instance of my custom document.
     */
    public XalDocument newDocument(java.net.URL url) {
        return new EmaDocument(url);
    }
    
    
    // --------- Global application management ---------------------------------
    
    
    /**
     * Specifies the name of my application.
     * @return Name of my application.
     */
    public String applicationName() {
        return "Ema";
    }
    
    
    /**
     * Specifies whether I want to send standard output and error to the console.
     * I don't need to override the superclass adaptor to return true (the default), but
     * it is sometimes convenient to disable the console while debugging.
     * @return Name of my application.
     */
    public boolean usesConsole() {
        String usesConsoleProperty = System.getProperty("usesConsole");
        if ( usesConsoleProperty != null ) {
            return Boolean.valueOf(usesConsoleProperty).booleanValue();
        }
        else {
            return true;
        }
    }
    
    
    // --------- Application events --------------------------------------------
    
    /** Capture the application launched event and print it */
    public void applicationFinishedLaunching() {
	    
        System.out.println("Application finished launching...");
    }
    
    
    /** The main method of the application. */
    static public void main(String[] args) {
        try {
            System.out.println("Launching Ema application...");
            AcceleratorApplication.launch( new Ema() );
        }
        catch(Exception exception) {
            System.err.println( exception.getMessage() );
            exception.printStackTrace();
            JOptionPane.showMessageDialog(null, exception.getMessage(), exception.getClass().getName(), JOptionPane.WARNING_MESSAGE);
        }
    }
}

@@ -1745,882 +1745,83 @@
    /
-**%0A     * Specifies whether I want to send standard output and error to the console.%0A     * I don't need to override the superclass adaptor to return true (the default), but%0A     * it is sometimes convenient to disable the console while debugging.%0A     * @return Name of my application.%0A     */%0A    public boolean usesConsole() %7B%0A        String usesConsoleProperty = System.getProperty(%22usesConsole%22);%0A        if ( usesConsoleProperty != null ) %7B%0A            return Boolean.valueOf(usesConsoleProperty).booleanValue();%0A        %7D%0A        else %7B%0A            return true;%0A        %7D%0A    %7D%0A    %0A    %0A    // --------- Application events --------------------------------------------%0A    %0A    /** Capture the application launched event and print it */%0A    public void applicationFinishedLaunching() %7B%0A%09    %0A        System.out.println(%22Application finished launching...%22);%0A    %7D%0A    
+/ --------- Application events --------------------------------------------
 %0A   

use functions from abstract class instead (refactoring)