public static void clear(boolean graphic) { ProjectFactory.getInstance() .setPromptDisabled(true); // prevent remove projects job from prompting to save Job job = ProjectFactory.getInstance().getPortfolio().getRemoveAllProjectsJob(null, false, null); SessionFactory.getInstance().getLocalSession().schedule(job); try { job.waitResult(); } catch (Exception e) { // TODO Auto-generated catch block e.printStackTrace(); } if (graphic) { GraphicManager gm = GraphicManager.getInstance(); if (gm != null) ((DefaultFrameManager) gm.getFrameManager()).cleanUp(false); } ProjectFactory.getInstance().getPortfolio().getObjectEventManager().removeAll(); ProjectFactory.getInstance().setPromptDisabled(false); // enable prompting again // Singletons, most of them can cause problems when it re-used. // Other singletons shouldn't be problem but have a cleanUp method just in case SessionFactory.cleanUp(); ProjectFactory.cleanUp(); ResourcePoolFactory.cleanUp(); UniqueIdPool.cleanUp(); MainFrame.cleanUp(); GraphicManager.cleanUpStatic(); StartupFactory.cleanUpStatic(); CalendarCatalog.cleanUp(); CalendarDefinition.cleanUp(); CalendarService.cleanUp(); WorkingCalendar.cleanUp(); AdvancedOption.cleanUp(); CalculationOption.cleanUp(); CalendarOption.cleanUp(); EditOption.cleanUp(); GanttOption.cleanUp(); GeneralOption.cleanUp(); ScheduleOption.cleanUp(); TimesheetOption.cleanUp(); FieldConverter.cleanUp(); ActionLists.cleanUp(); CellStyles.cleanUp(); Configuration.cleanUp(); Dictionary.cleanUp(); Factory.cleanUp(); ImportedCalendarService.cleanUp(); // remove dep NotAssignmentFilter.cleanUp(); NotVoidFilter.cleanUp(); HelpUtil.cleanUp(); ZeroFunctor.cleanUp(); NameCellComponent.cleanUp(); ScheduleService.cleanUp(); PageSizes.cleanUp(); ContextStore.cleanUp(); CustomFieldsMapper.cleanUp(); // remove dep }
public GraphicManager instanceFromNewSession(Container container, boolean doWelcome) { // DebugUtils.dumpStack("instanceFromNewSession being called "); VersionUtils.versionCheck(true); if (!VersionUtils.isJnlpUpToDate()) System.out.println( "Jnlp isn't up to date, current version is: " + VersionUtils.getJnlpVersion()); long t = System.currentTimeMillis(); log.info("New session"); Environment.setClientSide(true); System.setSecurityManager(null); Thread loadConfigThread = new Thread("loadConfig") { public void run() { long t = System.currentTimeMillis(); doLoadConfig(); } }; loadConfigThread.start(); GraphicManager graphicManager = GraphicManager.getInstance(); // normally null, unless reinit boolean recycling = graphicManager != null; // String projectUrl[]=null; try { if (Environment.isNoPodServer() || graphicManager == null) { graphicManager = new GraphicManager(/*projectUrl,*/ serverUrl, container); graphicManager.setStartupFactory(this); } else { reinitialize(); } } catch (HeadlessException e) { e.printStackTrace(); } graphicManager.setConnected(false); if (!doLogin(graphicManager)) return null; // if (Environment.isNewLook()) if (Environment.isNoPodServer() || !recycling) graphicManager.initLookAndFeel(); SessionFactory.getInstance().setJobQueue(graphicManager.getJobQueue()); PartnerInfo partnerInfo = null; if (!Environment.getStandAlone() && !Environment.isNoPodServer()) { Session session = SessionFactory.getInstance().getSession(false); try { partnerInfo = (PartnerInfo) SessionFactory.call(session, "retrievePartnerInfo", null, null); } catch (Exception e) { e.printStackTrace(); } } // System.out.println("---------- StartupFactory instanceFromNewSession#1 main done in // "+(System.currentTimeMillis()-t)+" ms"); try { loadConfigThread.join(); } catch (InterruptedException e1) { e1.printStackTrace(); } t = System.currentTimeMillis(); // System.out.println("---------- StartupFactory instanceFromNewSession#2"); // graphicManager.showWaitCursor(true); //TODO use a progress bar - maybe a Job if (partnerInfo != null) { if (partnerInfo.getConfigurationXML() != null) { ConfigurationReader.readString( partnerInfo.getConfigurationXML(), Configuration.getInstance()); Configuration.getInstance().setDonePopulating(); } if (partnerInfo.getViewXML() != null) { ConfigurationReader.readString(partnerInfo.getViewXML(), Dictionary.getInstance()); } } final GraphicManager gm = graphicManager; graphicManager.beginInitialization(); try { graphicManager.initView(); doStartupAction( graphicManager, projectId, (projectUrls == null && gm.getLastFileName() != null) ? new String[] {gm.getLastFileName()} : projectUrls, doWelcome, false, args); doPostInitView(graphicManager.getContainer()); // graphicManager.getContainer().applyComponentOrientation(ComponentOrientation.RIGHT_TO_LEFT); } finally { graphicManager.finishInitialization(); } instanceFromNewSessionDone = true; return graphicManager; }