List of usage examples for java.awt GraphicsEnvironment isHeadless
public static boolean isHeadless()
From source file:org.datacleaner.windows.OpenAnalysisJobAsTemplateDialogTest.java
@Test public void testRefreshOpenButtonVisibility() throws Exception { if (!GraphicsEnvironment.isHeadless()) { getDialog().refreshOpenButtonVisibility(); }//from w w w.j a v a2s.c o m }
From source file:org.datacleaner.windows.OpenAnalysisJobAsTemplateDialogTest.java
@Test public void testGetSourceColumnMapping() throws Exception { if (!GraphicsEnvironment.isHeadless()) { assertTrue(getDialog().getSourceColumnMapping() instanceof SourceColumnMapping); }/*from ww w . j a v a 2 s.com*/ }
From source file:org.datacleaner.windows.OpenAnalysisJobAsTemplateDialogTest.java
@Test public void testGetBannerTitle() throws Exception { if (!GraphicsEnvironment.isHeadless()) { assertEquals("Open as template", getDialog().getBannerTitle()); }/*ww w .j av a 2 s.c om*/ }
From source file:org.datacleaner.windows.OpenAnalysisJobAsTemplateDialogTest.java
@Test public void testGetDialogWidth() throws Exception { if (!GraphicsEnvironment.isHeadless()) { assertEquals(600, getDialog().getDialogWidth()); }/*from w w w . j a va 2s . c o m*/ }
From source file:org.datacleaner.windows.OpenAnalysisJobAsTemplateDialogTest.java
@Test public void testIsWindowResizable() throws Exception { if (!GraphicsEnvironment.isHeadless()) { assertEquals(true, getDialog().isWindowResizable()); }//from ww w . j a va 2 s . co m }
From source file:org.datacleaner.windows.OpenAnalysisJobAsTemplateDialogTest.java
@Test public void testGetDialogContent() throws Exception { if (!GraphicsEnvironment.isHeadless()) { assertTrue(getDialog().getDialogContent() instanceof JScrollPane); }/*w w w .jav a2s . co m*/ }
From source file:org.datacleaner.windows.OpenAnalysisJobAsTemplateDialogTest.java
@Test public void testGetWindowTitle() throws Exception { if (!GraphicsEnvironment.isHeadless()) { assertEquals("Open analysis job as template", getDialog().getWindowTitle()); }//from w w w .j a v a 2 s.c om }
From source file:org.eobjects.datacleaner.bootstrap.Bootstrap.java
private void runInternal() throws FileSystemException { logger.info("Welcome to DataCleaner {}", Version.getVersion()); // determine whether to run in command line interface mode final boolean cliMode = _options.isCommandLineMode(); final CliArguments arguments = _options.getCommandLineArguments(); logger.info("CLI mode={}, use -usage to view usage options", cliMode); if (cliMode) { if (!GraphicsEnvironment.isHeadless()) { // hide splash screen final SplashScreen splashScreen = SplashScreen.getSplashScreen(); if (splashScreen != null) { splashScreen.close();/* w ww. ja v a 2 s .c o m*/ } } if (arguments.isUsageMode()) { final PrintWriter out = new PrintWriter(System.out); try { CliArguments.printUsage(out); } finally { FileHelper.safeClose(out); } exitCommandLine(null, 1); return; } } if (!cliMode) { // set up error handling that displays an error dialog final DCUncaughtExceptionHandler exceptionHandler = new DCUncaughtExceptionHandler(); Thread.setDefaultUncaughtExceptionHandler(exceptionHandler); // init the look and feel LookAndFeelManager.get().init(); } // initially use a temporary non-persistent user preferences object. // This is just to have basic settings available for eg. resolving // files. final UserPreferences initialUserPreferences = new UserPreferencesImpl(null); final String configurationFilePath = arguments.getConfigurationFile(); final FileObject configurationFile = resolveFile(configurationFilePath, "conf.xml", initialUserPreferences); Injector injector = Guice.createInjector(new DCModule(DataCleanerHome.get(), configurationFile)); // configuration loading can be multithreaded, so begin early final AnalyzerBeansConfiguration configuration = injector.getInstance(AnalyzerBeansConfiguration.class); // log usage final UsageLogger usageLogger = injector.getInstance(UsageLogger.class); usageLogger.logApplicationStartup(); if (cliMode) { // run in CLI mode int exitCode = 0; final CliRunner runner = new CliRunner(arguments); try { runner.run(configuration); } catch (Throwable e) { logger.error("Error occurred while running DataCleaner command line mode", e); exitCode = 1; } finally { runner.close(); exitCommandLine(configuration, exitCode); } return; } else { // run in GUI mode final AnalysisJobBuilderWindow analysisJobBuilderWindow; // initialize Mac OS specific settings final MacOSManager macOsManager = injector.getInstance(MacOSManager.class); macOsManager.init(); // check for job file final String jobFilePath = _options.getCommandLineArguments().getJobFile(); if (jobFilePath != null) { final FileObject jobFile = resolveFile(jobFilePath, null, initialUserPreferences); injector = OpenAnalysisJobActionListener.open(jobFile, configuration, injector); } final UserPreferences userPreferences = injector.getInstance(UserPreferences.class); analysisJobBuilderWindow = injector.getInstance(AnalysisJobBuilderWindow.class); final Datastore singleDatastore; if (_options.isSingleDatastoreMode()) { DatastoreCatalog datastoreCatalog = configuration.getDatastoreCatalog(); singleDatastore = _options.getSingleDatastore(datastoreCatalog); if (singleDatastore == null) { logger.info("Single datastore mode was enabled, but datastore was null!"); } else { logger.info("Initializing single datastore mode with {}", singleDatastore); analysisJobBuilderWindow.setDatastoreSelectionEnabled(false); analysisJobBuilderWindow.setDatastore(singleDatastore, true); } } else { singleDatastore = null; } // show the window analysisJobBuilderWindow.open(); if (singleDatastore != null) { // this part has to be done after displaying the window (a lot // of initialization goes on there) final AnalysisJobBuilder analysisJobBuilder = analysisJobBuilderWindow.getAnalysisJobBuilder(); final DatastoreConnection con = singleDatastore.openConnection(); final InjectorBuilder injectorBuilder = injector.getInstance(InjectorBuilder.class); try { _options.initializeSingleDatastoreJob(analysisJobBuilder, con.getDataContext(), injectorBuilder); } finally { con.close(); } } final Image welcomeImage = _options.getWelcomeImage(); if (welcomeImage != null) { // Ticket #834: make sure to show welcome dialog in swing's // dispatch thread. WidgetUtils.invokeSwingAction(new Runnable() { @Override public void run() { final WelcomeDialog welcomeDialog = new WelcomeDialog(analysisJobBuilderWindow, welcomeImage); welcomeDialog.setVisible(true); } }); } final WindowContext windowContext = injector.getInstance(WindowContext.class); final HttpClient httpClient = injector.getInstance(HttpClient.class); // set up HTTP service for ExtensionSwap installation loadExtensionSwapService(userPreferences, windowContext, configuration, httpClient, usageLogger); final ExitActionListener exitActionListener = _options.getExitActionListener(); if (exitActionListener != null) { windowContext.addExitActionListener(exitActionListener); } } }
From source file:org.eobjects.datacleaner.bootstrap.Bootstrap.java
/** * Looks up a file, either based on a user requested filename (typically a * CLI parameter, may be a URL) or by a relative filename defined in the * system-/* ww w . j a v a 2 s. c o m*/ * * @param userRequestedFilename * the user requested filename, may be null * @param localFilename * the relative filename defined by the system * @param userPreferences * @return * @throws FileSystemException */ private FileObject resolveFile(final String userRequestedFilename, final String localFilename, UserPreferences userPreferences) throws FileSystemException { final FileObject dataCleanerHome = DataCleanerHome.get(); if (userRequestedFilename == null) { return dataCleanerHome.resolveFile(localFilename); } else { String lowerCaseFilename = userRequestedFilename.toLowerCase(); if (lowerCaseFilename.startsWith("http://") || lowerCaseFilename.startsWith("https://")) { if (!GraphicsEnvironment.isHeadless()) { // download to a RAM file. final FileObject targetDirectory = VFSUtils.getFileSystemManager() .resolveFile("ram:///datacleaner/temp"); if (!targetDirectory.exists()) { targetDirectory.createFolder(); } final URI uri; try { uri = new URI(userRequestedFilename); } catch (URISyntaxException e) { throw new IllegalArgumentException("Illegal URI: " + userRequestedFilename, e); } final WindowContext windowContext = new SimpleWindowContext(); @SuppressWarnings("resource") MonitorHttpClient httpClient = new SimpleWebServiceHttpClient(); MonitorConnection monitorConnection = null; // check if URI points to DC monitor. If so, make sure // credentials are entered. if (userPreferences != null && userPreferences.getMonitorConnection() != null) { monitorConnection = userPreferences.getMonitorConnection(); if (monitorConnection.matchesURI(uri)) { if (monitorConnection.isAuthenticationEnabled()) { if (monitorConnection.getEncodedPassword() == null) { final MonitorConnectionDialog dialog = new MonitorConnectionDialog( windowContext, userPreferences); dialog.openBlocking(); } monitorConnection = userPreferences.getMonitorConnection(); httpClient = monitorConnection.getHttpClient(); } } } try { final String[] urls = new String[] { userRequestedFilename }; final String[] targetFilenames = DownloadFilesActionListener.createTargetFilenames(urls); final FileObject[] files = downloadFiles(urls, targetDirectory, targetFilenames, windowContext, httpClient, monitorConnection); assert files.length == 1; final FileObject ramFile = files[0]; if (logger.isInfoEnabled()) { final InputStream in = ramFile.getContent().getInputStream(); try { final String str = FileHelper .readInputStreamAsString(ramFile.getContent().getInputStream(), "UTF8"); logger.info("Downloaded file contents: {}\n{}", userRequestedFilename, str); } finally { FileHelper.safeClose(in); } } final String scheme = uri.getScheme(); final int defaultPort; if ("http".equals(scheme)) { defaultPort = 80; } else { defaultPort = 443; } final UrlFileName fileName = new UrlFileName(scheme, uri.getHost(), uri.getPort(), defaultPort, null, null, uri.getPath(), FileType.FILE, uri.getQuery()); AbstractFileSystem fileSystem = (AbstractFileSystem) dataCleanerHome.getFileSystem(); return new DelegateFileObject(fileName, fileSystem, ramFile); } finally { httpClient.close(); userPreferences.setMonitorConnection(monitorConnection); } } } return VFSUtils.getFileSystemManager().resolveFile(userRequestedFilename); } }
From source file:org.eobjects.datacleaner.test.scenario.OpenAnalysisJobTest.java
/** * A very broad integration test which opens a job with (more or less) all * built-in analyzers.// ww w . j a v a2 s .c o m * * @throws Exception */ public void testOpenJobWithAllAnalyzers() throws Exception { if (GraphicsEnvironment.isHeadless()) { System.out.println("!!! Skipping test because environment is headless: " + getName()); return; } DCModule module = new DCModule(); Injector injector = Guice.createInjector(module); AnalyzerBeansConfiguration configuration = injector.getInstance(AnalyzerBeansConfiguration.class); FileObject file = VFSUtils.getFileSystemManager() .resolveFile("src/test/resources/all_analyzers.analysis.xml"); injector = OpenAnalysisJobActionListener.open(file, configuration, injector); AnalysisJobBuilderWindow window = injector.getInstance(AnalysisJobBuilderWindow.class); assertNotNull(window); assertEquals("all_analyzers.analysis.xml", window.getJobFile().getName().getBaseName()); ((AnalysisJobBuilderWindowImpl) window).updateStatusLabel(); assertEquals("Job is correctly configured", window.getStatusLabelText()); }