/** * Class constructor alloowing specification of the heading text. * * @param properties the Properties object containing the initial values of the extensions list * and the path to be displayed. This object is updated tin response to root changes, * extension changes, and file selections. If any property is missing, a suitable one is * supplied by default. * @param heading the text to appear in the heading of the JPanel. * @param background the background color or null if the default is to be used. */ public SourcePanel(ApplicationProperties properties, String heading, Color background) { super(); this.properties = properties; if (background == null) this.background = Color.getHSBColor(0.58f, 0.17f, 0.95f); else this.background = background; // Make the file filter filter = new GeneralFileFilter(); String extensions = properties.getProperty("extensions"); if (extensions != null) filter.setExtensions(extensions); else { filter.addExtension(".dcm"); properties.setProperty("extensions", filter.getExtensionString()); } // Get the starting directory path from the properties. // If it is missing, start in the directory containing the program. String currentDirectoryPath = properties.getProperty("directory"); if (currentDirectoryPath == null) currentDirectoryPath = System.getProperty("user.dir"); // Create the UI components this.setLayout(new BorderLayout()); directoryPane = new DirectoryPane(filter, currentDirectoryPath); directoryPane.addFileListener(this); headerPanel = new HeaderPanel(heading); footerPanel = new FooterPanel(); this.add(headerPanel, BorderLayout.NORTH); this.add(directoryPane, BorderLayout.CENTER); this.add(footerPanel, BorderLayout.SOUTH); }
/** * The FileEvent listener. * * @param event the event. */ public void fileEventOccurred(FileEvent event) { File file = event.getFile(); if (file != null) { String dirPath; if (file.isDirectory()) dirPath = file.getAbsolutePath(); else dirPath = file.getParentFile().getAbsolutePath(); properties.setProperty("directory", dirPath); } else properties.remove("directory"); }
/** @param props The properties set from the properties file */ public JsoupWrapper(final ApplicationProperties props, final boolean initialize) throws IOException { this.props = props; this.cookies = new HashMap<>(); this.userAgent = props.getUserAgent(); this.timeoutInMilliseconds = props.getConnectionTimeout(); if (initialize) { this.init(); } }
/** Initializes the application */ public void init() throws ServletException { Debug.info( "******* UniTime " + Constants.getVersion() + " build on " + Constants.getReleaseDate() + " is starting up *******"); super.init(); try { Debug.info(" - Initializing Logging ... "); Debug.init(ApplicationProperties.getProperties()); Debug.info(" - Initializing Hibernate ... "); _RootDAO.initialize(); Debug.info(" - Initializing Solver Register ... "); SolverRegisterService.startService(); SolverRegisterService.addShutdownHook(); if (RoomAvailability.getInstance() != null) { Debug.info(" - Initializing Room Availability Service ... "); RoomAvailability.getInstance().startService(); } Debug.info(" - Cleaning Logs ..."); LogCleaner.cleanupLogs(); Debug.info(" - Starting Online Sectioning Service ..."); OnlineSectioningService.startService(); Debug.info( "******* UniTime " + Constants.getVersion() + " build on " + Constants.getReleaseDate() + " initialized successfully *******"); } catch (Exception e) { Debug.error("UniTime Initialization Failed : " + e.getMessage(), e); sInitializationException = e; } }
/** * @param connection Jsoup connection object * @param method HTTP method * @return Jsoup Connection.Response object */ public Connection.Response execute(Connection connection, Connection.Method method) { Connection.Response response; if (method != null) { connection.method(method); } try { System.out.println("Calling " + connection.request().url()); if (props.getMode() == Mode.TEST) { return null; } response = connection.execute(); } catch (IOException e) { e.printStackTrace(); return null; } this.cookies.putAll(response.cookies()); return response; }
/** Terminates the application */ public void destroy() { try { Debug.info( "******* UniTime " + Constants.getVersion() + " build on " + Constants.getReleaseDate() + " is going down *******"); super.destroy(); Debug.info(" - Stopping Online Sectioning Service ..."); OnlineSectioningService.stopService(); Debug.info(" - Stopping Solver Register ... "); SolverRegisterService.stopService(); try { SolverRegisterService.removeShutdownHook(); } catch (IllegalStateException e) { } SolverInfo.stopInfoCacheCleanup(); ApplicationProperties.stopListener(); if (RoomAvailability.getInstance() != null) { Debug.info(" - Stopping Room Availability Service ... "); RoomAvailability.getInstance().stopService(); } QueueProcessor.stopProcessor(); Debug.info("******* UniTime " + Constants.getVersion() + " shut down successfully *******"); } catch (Exception e) { Debug.error("UniTime Shutdown Failed : " + e.getMessage(), e); if (e instanceof RuntimeException) throw (RuntimeException) e; else throw new RuntimeException("UniTime Shutdown Failed : " + e.getMessage(), e); } }
/** Makes initial call to setup the cookies */ public void init() throws IOException { Connection connection = this.connect(props.getBaseUrl()); // This initial get requests sets our jsoupWrapper with appropriate cookies this.get(connection); }