1 6 package com.nightlabs.ipanema.base.app; 7 8 import javax.security.auth.login.LoginException ; 9 10 import org.eclipse.swt.widgets.Display; 11 import org.eclipse.ui.PlatformUI; 12 import org.eclipse.ui.application.WorkbenchAdvisor; 13 14 import com.nightlabs.ipanema.base.login.Login; 15 import com.nightlabs.ipanema.base.login.LoginConfigModule; 16 import com.nightlabs.ipanema.update.StartupUpdateManager; 17 18 21 public class IpanemaApplicationThread extends Thread 22 { 23 24 public static final String DEFAULT_NAME = "IpanemaApplicationThread"; 25 26 public IpanemaApplicationThread() 27 { 28 this(DEFAULT_NAME); 29 } 30 31 34 public IpanemaApplicationThread(Runnable target) { 35 super(target); 36 } 37 38 41 public IpanemaApplicationThread(String name) { 42 super(name); 43 } 44 45 49 public IpanemaApplicationThread(ThreadGroup group, Runnable target) { 50 super(group, target); 51 } 52 53 57 public IpanemaApplicationThread(Runnable target, String name) { 58 super(target, name); 59 } 60 61 public IpanemaApplicationThread(ThreadGroup group) { 62 super(group, DEFAULT_NAME); 63 } 64 65 69 public IpanemaApplicationThread(ThreadGroup group, String name) { 70 super(group, name); 71 } 72 73 78 public IpanemaApplicationThread(ThreadGroup group, Runnable target, 79 String name) { 80 super(group, target, name); 81 } 82 83 89 public IpanemaApplicationThread(ThreadGroup group, Runnable target, 90 String name, long stackSize) { 91 super(group, target, name, stackSize); 92 } 93 94 private IpanemaApplication application; 95 void setIpanemaApplication(IpanemaApplication app) { 96 this.application = app; 97 } 98 99 100 private int platformResultCode = -1; 101 protected Display display; 102 103 public int getPlatformResultCode() { 104 return platformResultCode; 105 } 106 107 public void run() { 108 try { 109 display = PlatformUI.createDisplay(); 111 112 WorkbenchAdvisor workbenchAdvisor = new IpanemaWorkbenchAdvisor(display); 113 114 try 115 { 116 LoginConfigModule lcm = Login.getLogin().getLoginConfigModule(); 117 if(lcm.getAutomaticUpdate() == true) 118 { 119 StartupUpdateManager updateManager = new StartupUpdateManager(lcm); 120 updateManager.run(); 121 if(updateManager.doRestart()) 122 { 123 platformResultCode = PlatformUI.RETURN_RESTART; 124 return; 125 } 126 } 127 } 128 catch(LoginException e) 129 { 130 } 131 132 133 int returnCode = PlatformUI.createAndRunWorkbench(display, workbenchAdvisor); 134 } 135 finally { 136 synchronized(IpanemaApplication.getMutex()) { 137 IpanemaApplication.getMutex().notifyAll(); 138 } 139 } 140 } 141 } 142 | Popular Tags |