Package com.apple.mrj

Source Code of com.apple.mrj.MRJPriv$MRJQuitApplicationAdapter

/*     */ package com.apple.mrj;
/*     */
/*     */ import com.apple.eawt.Application;
/*     */ import com.apple.eawt.ApplicationAdapter;
/*     */ import com.apple.eawt.ApplicationEvent;
/*     */ import com.apple.eio.FileManager;
/*     */ import java.awt.Menu;
/*     */ import java.awt.MenuItem;
/*     */ import java.awt.MenuShortcut;
/*     */ import java.io.File;
/*     */ import java.io.FileNotFoundException;
/*     */ import java.io.IOException;
/*     */
/*     */ class MRJPriv
/*     */ {
/*     */   static boolean setFileLastModified(File file, long aDate)
/*     */   {
/* 139 */     return file.setLastModified(aDate);
/*     */   }
/*     */
/*     */   static void setDefaultFileType(MRJOSType defaultType)
/*     */   {
/*     */   }
/*     */
/*     */   static void setDefaultFileCreator(MRJOSType defaultCreator)
/*     */   {
/*     */   }
/*     */
/*     */   static void doSetFile(File file, MRJOSType type, MRJOSType creator) throws IOException {
/*     */     try {
/* 152 */       FileManager.setFileTypeAndCreator(file.toString(), type.toInt(), creator.toInt());
/*     */     }
/*     */     catch (IOException e) {
/* 155 */       throw e;
/*     */     }
/*     */   }
/*     */
/*     */   static final void setFileTypeAndCreator(File file, MRJOSType type, MRJOSType creator) throws IOException {
/* 160 */     doSetFile(file, type, creator);
/*     */   }
/*     */
/*     */   static final void setFileType(File file, MRJOSType type) throws IOException {
/*     */     try {
/* 165 */       FileManager.setFileType(file.toString(), type.toInt());
/*     */     }
/*     */     catch (IOException e) {
/* 168 */       throw e;
/*     */     }
/*     */   }
/*     */
/*     */   static final void setFileCreator(File file, MRJOSType creator) throws IOException {
/*     */     try {
/* 174 */       FileManager.setFileType(file.toString(), creator.toInt());
/*     */     }
/*     */     catch (IOException e) {
/* 177 */       throw e;
/*     */     }
/*     */   }
/*     */
/*     */   static final MRJOSType getFileType(File file) throws IOException {
/*     */     try {
/* 183 */       return new MRJOSType(FileManager.getFileType(file.toString()));
/*     */     }
/*     */     catch (IOException e) {
/* 186 */       throw e;
/*     */     }
/*     */   }
/*     */
/*     */   static final MRJOSType getFileCreator(File file) throws IOException {
/*     */     try {
/* 192 */       return new MRJOSType(FileManager.getFileCreator(file.toString()));
/*     */     }
/*     */     catch (IOException e) {
/* 195 */       throw e;
/*     */     }
/*     */   }
/*     */
/*     */   static File findFolder(MRJOSType folderType)
/*     */     throws FileNotFoundException
/*     */   {
/*     */     try
/*     */     {
/* 208 */       return new File(FileManager.findFolder(folderType.toInt()));
/*     */     }
/*     */     catch (FileNotFoundException e) {
/* 211 */       throw e;
/*     */     }
/*     */   }
/*     */
/*     */   static File findFolder(short domain, MRJOSType folderType)
/*     */     throws FileNotFoundException
/*     */   {
/*     */     try
/*     */     {
/* 224 */       return new File(FileManager.findFolder(domain, folderType.toInt()));
/*     */     }
/*     */     catch (FileNotFoundException e) {
/* 227 */       throw e;
/*     */     }
/*     */   }
/*     */
/*     */   static File findFolder(short domain, MRJOSType folderType, boolean createIfNeeded)
/*     */     throws FileNotFoundException
/*     */   {
/*     */     try
/*     */     {
/* 241 */       return new File(FileManager.findFolder(domain, folderType.toInt(), createIfNeeded));
/*     */     }
/*     */     catch (FileNotFoundException e) {
/* 244 */       throw e;
/*     */     }
/*     */   }
/*     */
/*     */   static File findApplication(MRJOSType applSig) throws FileNotFoundException
/*     */   {
/* 250 */     return null;
/*     */   }
/*     */
/*     */   static void openURL(String url) throws IOException {
/*     */     try {
/* 255 */       FileManager.openURL(url);
/*     */     }
/*     */     catch (IOException e) {
/* 258 */       throw e;
/*     */     }
/*     */   }
/*     */
/*     */   static File getBundleResource(String resourceName, String subDirName)
/*     */     throws FileNotFoundException
/*     */   {
/*     */     try
/*     */     {
/* 273 */       return new File(FileManager.getResource(resourceName, subDirName));
/*     */     }
/*     */     catch (FileNotFoundException e) {
/* 276 */       throw e;
/*     */     }
/*     */   }
/*     */
/*     */   static synchronized void registerAboutHandler(MRJAboutHandler handler) {
/* 281 */     Application fApplication = new Application();
/* 282 */     ApplicationAdapter fAdapter = new MRJAboutApplicationAdapter(handler);
/*     */
/* 284 */     fApplication.addApplicationListener(fAdapter);
/*     */   }
/*     */
/*     */   static synchronized void registerOpenApplicationHandler(MRJOpenApplicationHandler handler) {
/* 288 */     Application fApplication = new Application();
/* 289 */     ApplicationAdapter fAdapter = new MRJOpenApplicationApplicationAdapter(handler);
/*     */
/* 291 */     fApplication.addApplicationListener(fAdapter);
/*     */   }
/*     */
/*     */   static synchronized void registerOpenDocumentHandler(MRJOpenDocumentHandler handler) {
/* 295 */     Application fApplication = new Application();
/* 296 */     ApplicationAdapter fAdapter = new MRJOpenDocumentApplicationAdapter(handler);
/*     */
/* 298 */     fApplication.addApplicationListener(fAdapter);
/*     */   }
/*     */
/*     */   static synchronized void registerPrintDocumentHandler(MRJPrintDocumentHandler handler) {
/* 302 */     Application fApplication = new Application();
/* 303 */     ApplicationAdapter fAdapter = new MRJPrintDocumentApplicationAdapter(handler);
/*     */
/* 305 */     fApplication.addApplicationListener(fAdapter);
/*     */   }
/*     */
/*     */   static synchronized void registerQuitHandler(MRJQuitHandler handler) {
/* 309 */     Application fApplication = new Application();
/* 310 */     ApplicationAdapter fAdapter = new MRJQuitApplicationAdapter(handler);
/*     */
/* 312 */     fApplication.addApplicationListener(fAdapter);
/*     */   }
/*     */
/*     */   static synchronized void registerPrefsHandler(MRJPrefsHandler handler) {
/* 316 */     Application fApplication = new Application();
/* 317 */     ApplicationAdapter fAdapter = new MRJPreferencesApplicationAdapter(handler);
/*     */
/* 319 */     fApplication.setEnabledPreferencesMenu(true);
/* 320 */     fApplication.addApplicationListener(fAdapter);
/*     */   }
/*     */
/*     */   static final void setMenuItemCmdKey(Menu menu, int item, char ch)
/*     */   {
/* 327 */     setMenuItemCmdKey(menu.getItem(item), ch);
/*     */   }
/*     */
/*     */   static final void setMenuItemCmdKey(MenuItem item, char ch) {
/* 331 */     item.setShortcut(new MenuShortcut(ch, false));
/*     */   }
/*     */
/*     */   static final boolean isMRJToolkitAvailable() {
/* 335 */     return false;
/*     */   }
/*     */
/*     */   private static class MRJQuitApplicationAdapter extends ApplicationAdapter
/*     */   {
/*     */     MRJQuitHandler handler;
/*     */
/*     */     public MRJQuitApplicationAdapter(MRJQuitHandler o)
/*     */     {
/* 411 */       this.handler = o;
/*     */     }
/*     */
/*     */     public void handleQuit(ApplicationEvent e) {
/*     */       try {
/* 416 */         this.handler.handleQuit();
/*     */       }
/*     */       catch (IllegalStateException ex) {
/* 419 */         e.setHandled(false);
/*     */       }
/*     */     }
/*     */   }
/*     */
/*     */   private static class MRJPreferencesApplicationAdapter extends ApplicationAdapter
/*     */   {
/*     */     MRJPrefsHandler handler;
/*     */
/*     */     public MRJPreferencesApplicationAdapter(MRJPrefsHandler o)
/*     */     {
/* 398 */       this.handler = o;
/*     */     }
/*     */
/*     */     public void handlePreferences(ApplicationEvent e) {
/* 402 */       this.handler.handlePrefs();
/*     */     }
/*     */   }
/*     */
/*     */   private static class MRJPrintDocumentApplicationAdapter extends ApplicationAdapter
/*     */   {
/*     */     MRJPrintDocumentHandler handler;
/*     */
/*     */     public MRJPrintDocumentApplicationAdapter(MRJPrintDocumentHandler o)
/*     */     {
/* 385 */       this.handler = o;
/*     */     }
/*     */
/*     */     public void handlePrintFile(ApplicationEvent e) {
/* 389 */       this.handler.handlePrintFile(new File(e.getFilename()));
/*     */     }
/*     */   }
/*     */
/*     */   private static class MRJOpenDocumentApplicationAdapter extends ApplicationAdapter
/*     */   {
/*     */     MRJOpenDocumentHandler handler;
/*     */
/*     */     public MRJOpenDocumentApplicationAdapter(MRJOpenDocumentHandler o)
/*     */     {
/* 372 */       this.handler = o;
/*     */     }
/*     */
/*     */     public void handleOpenFile(ApplicationEvent e) {
/* 376 */       this.handler.handleOpenFile(new File(e.getFilename()));
/*     */     }
/*     */   }
/*     */
/*     */   private static class MRJOpenApplicationApplicationAdapter extends ApplicationAdapter
/*     */   {
/*     */     MRJOpenApplicationHandler handler;
/*     */
/*     */     public MRJOpenApplicationApplicationAdapter(MRJOpenApplicationHandler o)
/*     */     {
/* 359 */       this.handler = o;
/*     */     }
/*     */
/*     */     public void handleOpenApplication(ApplicationEvent e) {
/* 363 */       this.handler.handleOpenApplication();
/*     */     }
/*     */   }
/*     */
/*     */   private static class MRJAboutApplicationAdapter extends ApplicationAdapter
/*     */   {
/*     */     MRJAboutHandler handler;
/*     */
/*     */     public MRJAboutApplicationAdapter(MRJAboutHandler o)
/*     */     {
/* 345 */       this.handler = o;
/*     */     }
/*     */
/*     */     public void handleAbout(ApplicationEvent e) {
/* 349 */       this.handler.handleAbout();
/* 350 */       e.setHandled(true);
/*     */     }
/*     */   }
/*     */ }

/* Location:           Z:\System\Library\Java\Extensions\MRJToolkit.jar
* Qualified Name:     com.apple.mrj.MRJPriv
* JD-Core Version:    0.6.2
*/
TOP

Related Classes of com.apple.mrj.MRJPriv$MRJQuitApplicationAdapter

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.