當前位置: 首頁>>代碼示例>>Java>>正文


Java Application.setOpenFileHandler方法代碼示例

本文整理匯總了Java中com.apple.eawt.Application.setOpenFileHandler方法的典型用法代碼示例。如果您正苦於以下問題:Java Application.setOpenFileHandler方法的具體用法?Java Application.setOpenFileHandler怎麽用?Java Application.setOpenFileHandler使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在com.apple.eawt.Application的用法示例。


在下文中一共展示了Application.setOpenFileHandler方法的10個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: install

import com.apple.eawt.Application; //導入方法依賴的package包/類
static void install() {
    try {
        Application app = Application.getApplication();
        NbApplicationAdapterJDK8 al = new NbApplicationAdapterJDK8();

        app.setAboutHandler(al);
        app.setOpenFileHandler(al);
        app.setPreferencesHandler(al);
        app.setQuitHandler(al);
    } catch (Throwable ex) {
        ErrorManager.getDefault().notify(ErrorManager.WARNING, ex);
    } finally {
    }
    NbApplicationAdapter.install();
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:16,代碼來源:NbApplicationAdapterJDK8.java

示例2: uninstall

import com.apple.eawt.Application; //導入方法依賴的package包/類
static void uninstall() {
    Application app = Application.getApplication();

    app.setAboutHandler(null);
    app.setOpenFileHandler(null);
    app.setPreferencesHandler(null);
    app.setQuitHandler(null);
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:9,代碼來源:NbApplicationAdapterJDK8.java

示例3: App

import com.apple.eawt.Application; //導入方法依賴的package包/類
/** Creates a new {@link App}. */
protected App() {
	if (Platform.isMacintosh()) {
		Application app = Application.getApplication();
		app.setAboutHandler(AboutCommand.INSTANCE);
		app.setPreferencesHandler(PreferencesCommand.INSTANCE);
		app.setOpenFileHandler(OpenCommand.INSTANCE);
		app.setPrintFileHandler(PrintCommand.INSTANCE);
		app.setQuitHandler(QuitCommand.INSTANCE);
		app.setQuitStrategy(QuitStrategy.SYSTEM_EXIT_0);
		app.disableSuddenTermination();
	}
}
 
開發者ID:Ayutac,項目名稱:toolkit,代碼行數:14,代碼來源:App.java

示例4: MacOSAppEventDispatcher

import com.apple.eawt.Application; //導入方法依賴的package包/類
public MacOSAppEventDispatcher(final Application app,
	final EventService eventService)
{
	this.eventService = eventService;
	app.setAboutHandler(this);
	app.setPreferencesHandler(this);
	app.setPrintFileHandler(this);
	app.setQuitHandler(this);
	app.addAppEventListener(this);
	app.setOpenFileHandler(this);
}
 
開發者ID:scijava,項目名稱:scijava-plugins-platforms,代碼行數:12,代碼來源:MacOSAppEventDispatcher.java

示例5: initialize

import com.apple.eawt.Application; //導入方法依賴的package包/類
@Override
public void initialize(ChmWebApp app) {
    this.app = app;
    Application a = Application.getApplication();
    a.setOpenFileHandler(this);
}
 
開發者ID:chimenchen,項目名稱:jchmlib,代碼行數:7,代碼來源:ChmWebAppMacSupport.java

示例6: handleFileActivation

import com.apple.eawt.Application; //導入方法依賴的package包/類
/**
 * Handle file activation via macOS open-file.
 *
 * @param controller the controller to use.
 */
public static void handleFileActivation(Controller controller) {
    //First, check for if we are on OS X so that it doesn't execute on
    //other platforms. Note that we are using contains() because it was
    //called Mac OS X before 10.8 and simply OS X afterwards
    if (System.getProperty("os.name").contains("OS X")) {
        final org.tros.utils.logging.Logger logger = org.tros.utils.logging.Logging.getLogFactory().getLogger(MainMac.class);
        Application a = Application.getApplication();
        a.setOpenFileHandler((AppEvent.OpenFilesEvent e) -> {
            e.getFiles().forEach((file2) -> {
                File file = (File) file2;
                logger.info("FILE: {0}", file.getAbsolutePath());
                int index = file.getName().lastIndexOf('.');
                String lang = "dynamic-logo";
                String ext;
                if (index >= 0) {
                    ext = file.getName().substring(index + 1);
                    if (ext != null && TorgoToolkit.getToolkits().contains(ext)) {
                        lang = ext;
                    }
                }
                logger.info("LANG: {0}", lang);
                if (lang.equals(controller.getLang())) {
                    controller.openFile(file);
                } else {
                    java.util.prefs.Preferences prefs = java.util.prefs.Preferences.userNodeForPackage(TorgoToolkit.class);
                    prefs.put("lang", lang);

                    controller.close();
                    Controller controller2 = TorgoToolkit.getController(lang);
                    SwingUtilities.invokeLater(() -> {
                        if (controller2 != null) {
                            controller2.run();
                            controller2.openFile(file);
                        }
                    });
                }
            });
        });
    }
}
 
開發者ID:ZenHarbinger,項目名稱:torgo,代碼行數:46,代碼來源:MainMac.java

示例7: setListener

import com.apple.eawt.Application; //導入方法依賴的package包/類
@Override
public void setListener(final ExternalEventListener listener) {
    Application application = Application.getApplication();

    application.setOpenFileHandler(new OsxOpenFilesHandler(listener));
}
 
開發者ID:VocabHunter,項目名稱:VocabHunter,代碼行數:7,代碼來源:OsxEventSource.java

示例8: main

import com.apple.eawt.Application; //導入方法依賴的package包/類
public static void main( String[] args )
{
    try {
        // These four lines duplicate ApplicationUI.main()
        String prop = System .getProperty( "user.dir" );
        File workingDir = new File( prop );
        URL codebase = workingDir .toURI() .toURL();
        final ApplicationUI ui = ApplicationUI .initialize( args, codebase );
        
        // Now hook it up to the Finder events
        Application appl = Application .getApplication();
        
        appl .setOpenFileHandler( new OpenFilesHandler()
        {
            public void openFiles( OpenFilesEvent ofe )
            {
                for (Iterator iterator = ofe .getFiles() .iterator(); iterator.hasNext(); ) {
                    File file = (File) iterator.next();
                    ui .openFile( file );
                }
            }
        } );
        
        appl .setAboutHandler( new AboutHandler()
        {
            public void handleAbout( AboutEvent about )
            {
                ui .about();
            }
        } );
        
        appl .setQuitHandler( new QuitHandler()
        {
            public void handleQuitRequestWith( QuitEvent qe, QuitResponse qr )
            {
                if ( ui .quit() )
                    qr .performQuit();
                else
                    qr .cancelQuit();
                    
            }
        } );    

    } catch ( Throwable e ) {
        Logger .getLogger( "com.vzome.platform.mac.Adapter" )
            .log( Level.SEVERE, "problem in main()", e );
    }
}
 
開發者ID:vZome,項目名稱:vzome-desktop,代碼行數:49,代碼來源:Adapter.java

示例9: main

import com.apple.eawt.Application; //導入方法依賴的package包/類
/**
 * UiLOTSVideoCodingSystem method tries to add VLC to the search path of this application
 * If this fails, a dialog is opened, asking the user to specify where
 * VLC is installed. Otherwise, the application itself is started
 * 
 * @param args 		-f: fails finding VLC automatically, to test a new
 * 						path while the program would otherwise recognise
 * 						VLC
 * 
 * 					-vlc="<path>": Specify the VLC path. Useful for installers
 * 
 * 					String: Specify the project that the user would like to open
 * 							Required for automatic file association
 */
public static void main(String[] args) {
	LoadingPanel p = new LoadingPanel();
	
	if (Globals.getOs() == Globals.OsType.Mac){
		Application a = Application.getApplication();
		p.updateMsg("Checking Mac OS compatibility...");
		a.setOpenFileHandler(new OpenFilesHandler() {
			@Override
			public void openFiles(OpenFilesEvent e) {
				
				@SuppressWarnings("unchecked")
				List<File> files = e.getFiles();
				if(files.size() > 1){
					JOptionPane.showMessageDialog(new JPanel(), 
							"Only one file can be opened at the time with this application", 
							"Can only open one file",
							JOptionPane.WARNING_MESSAGE);
				}
				openExisting = true;
				existing = files.get(0).getAbsolutePath();
			}
		});
	}
	
	prefs = new ApplicationPreferences();
	p.updateMsg("Initializing application preferences...");
	
	p.updateMsg("Processing arguments..");
	if(args.length > 0) handleArguments(args);
	
	p.updateMsg("Searching for VLC");
	if(vlc_location != null)
		searchDefaultPaths();
	searchPreferencedPath();
	
	if(vlcFound() && !fail_find_vlc)
	{
		p.updateMsg("Initializing application view...");
		// Only starts the main application after VLC has been found
		Globals g = Globals.getInstance();
		g.debug(DEBUG);
		
		if(!openExisting) {
			p.updateMsg("Starting new project...");
			g.showNewProject();
		}
		else {
			p.updateMsg("Opening project...");
			g.open(existing);
		}
	} else {
		SwingUtilities.invokeLater(new Runnable(){
			@Override
			public void run(){
				view.panels.VLCNotFound vlcError = new view.panels.VLCNotFound(prefs);
				vlcError.setVisible(true);
			}
		});
	}
	p.dispose();
}
 
開發者ID:UiL-OTS-labs-backoffice,項目名稱:UiL-OTS-Video-Coding-System,代碼行數:76,代碼來源:UiLOTSVideoCodingSystem.java

示例10: doInstallOpenFilesHandler

import com.apple.eawt.Application; //導入方法依賴的package包/類
/**
 * When the user requests to open (a) file(s) associated with the
 * application, invokes the specified handler on the event dispatch thread.
 *
 * @param openFilesHandler The handler to invoke.
 * @return <code>true</code> if the handler was successfully installed;
 *     <code>false</code> if the Apple Java extensions cannot be found or
 *     are too old.
 */
protected boolean doInstallOpenFilesHandler(final MacUtils.OpenFilesHandler openFilesHandler) {
    Application application = Application.getApplication();
    application.setOpenFileHandler(openFilesEvent -> {
        final List<File> files = openFilesEvent.getFiles();
        AwtUtils.doLaterOnEventThread(() -> openFilesHandler.filesOpened(files));
    });
    return true;
}
 
開發者ID:Captain-Chaos,項目名稱:WorldPainter,代碼行數:18,代碼來源:MacUtilsJava8.java


注:本文中的com.apple.eawt.Application.setOpenFileHandler方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。