/** * Returns the current repaint manager. * * @return a repaint manager, can be <code>null</code>. */ private static Object currentRepaintManager() { try { final java.lang.reflect.Method method = SwingUtilities.class.getMethod( "appContextGet", Object.class ); method.setAccessible( true ); return method.invoke( null, RepaintManager.class ); } catch ( final Exception exception ) { // Make sure to handle IO-interrupted exceptions properly! HostUtils.handleInterruptedException( exception ); return null; } }
HostUtils.closeResource( is ); resource = null;
/** * Returns the file-object pointing to a user-settings file. * * @return a user-settings file-object, never <code>null</code>. */ private File getUserSettingsFile() { return HostUtils.createLocalDataFile( IMPLICIT_USER_SETTING_NAME_PREFIX, IMPLICIT_USER_SETTING_NAME_SUFFIX ); }
/** * Saves the project file. * * @param aOwner * the owning/parent window; * @param aFile * the file to save the project to. */ protected void saveProjectFile( final Window aOwner, final File aFile ) { LOG.log( Level.INFO, "Saving project data to file: {0}", aFile ); // Strip any "known" file extensions from the given value... final String projectName = HostUtils.stripFileExtension( aFile, OpenDataFileAction.OLS_FILE_EXTENSION, OpenProjectAction.OLS_PROJECT_EXTENSION ); try { getController().saveProjectFile( projectName, aFile ); } catch ( IOException exception ) { // Make sure to handle IO-interrupted exceptions properly! if ( !HostUtils.handleInterruptedException( exception ) ) { LOG.log( Level.WARNING, "Saving OLS project failed!", exception ); JErrorDialog.showDialog( aOwner, "Saving the project data failed!", exception ); } } }
if ( !HostUtils.handleInterruptedException( exception ) ) HostUtils.closeResource( this.outputStream ); HostUtils.closeResource( this.inputStream );
if ( file != null ) final File actualFile = HostUtils.setFileExtension( file, OpenDataFileAction.OLS_FILE_EXTENSION ); if ( !HostUtils.handleInterruptedException( exception ) )
if ( !HostUtils.handleInterruptedException( exception ) ) HostUtils.reverse( samples );
/** * @return the input modifier to distinguish between scroll events and zoom * events. */ private int getMouseWheelZoomModifier() { final HostInfo hostInfo = HostUtils.getHostInfo(); if ( hostInfo.isMacOS() ) { return InputEvent.META_DOWN_MASK; } return InputEvent.CTRL_DOWN_MASK; }
/** * Returns the "presumed" filename extension (like '.jpg', '.zip') from a * given file. * * @param aFile * the file to return the extension for, cannot be <code>null</code>. * @return the file extension (always in lower case), never <code>null</code> * but can be empty if the given file has <em>no</em> file extension. */ public static final String stripFileExtension( final File aFile, final String... aExtensions ) { return stripFileExtension( aFile.getName(), aExtensions ); }
final File actualFile = HostUtils.setFileExtension( exportFileName, preferredExtension ); if ( LOG.isLoggable( Level.INFO ) ) if ( !HostUtils.handleInterruptedException( exception ) )
/** * Determines a foreground color for the separator label. */ private static Color getSeparatorForegroundColor() { if ( selectionColor == null ) { if ( HostUtils.getHostInfo().isMacOS() ) { selectionColor = UIManager.getColor( "List.selectionBackground" ); } else { selectionColor = UIManager.getColor( "MenuItem.selectionBackground" ); } if ( selectionColor == null ) { selectionColor = Color.BLUE; } } return selectionColor; }
/** * Stores the given analysis results to the given file as HTML. * * @param aSelectedFile * @param aAnalysisResult */ private void storeToHtmlFile( final File aSelectedFile, final I2CDataSet aAnalysisResult ) { try { toHtmlPage( aSelectedFile, aAnalysisResult ); } catch ( final IOException exception ) { // Make sure to handle IO-interrupted exceptions properly! if ( !HostUtils.handleInterruptedException( exception ) ) { LOG.log( Level.WARNING, "HTML export failed!", exception ); } } }
HostUtils.closeResource( zipIS ); HostUtils.closeResource( is );
if ( HostUtils.getHostInfo().isWindows() && ( uriStr.length() > MAGIC_WINDOWS_URI_LIMIT ) )
/** * Creates an OS-specific file location to store properties. * * @param aName * the name of the properties file, excluding <tt>.properties</tt>, * cannot be <code>null</code> or empty. By convention, the name of a * properties file should be in the "reverse package name", e.g., * "com.foo.bar". * @return the file pointing to the OS-specific properties file location, * never <code>null</code>. */ public static final File createLocalPropertiesFile( final String aName ) { return createLocalDataFile( aName, "properties" ); }
/** * stores the data to a HTML file * * @param aFile * file object */ private void storeToHtmlFile( final File aFile, final SPIDataSet aDataSet ) { try { toHtmlPage( aFile, aDataSet ); } catch ( final IOException exception ) { // Make sure to handle IO-interrupted exceptions properly! if ( !HostUtils.handleInterruptedException( exception ) ) { LOG.log( Level.WARNING, "HTML export failed!", exception ); } } }
HostUtils.closeResource( os );
/** * Adds a labeled separator to the given container. * * @param aContainer * the container to add the separator + label to, cannot be * <code>null</code>. * @param aText * the (optional) text of the label to add, may be <code>null</code>. * @return the given container, never <code>null</code>. */ public static final Container addSeparator( final Container aContainer, final String aText ) { final Color color = getSeparatorForegroundColor(); final JLabel label = new JLabel( aText ); label.setAlignmentY( Component.BOTTOM_ALIGNMENT ); // Take the selection color of a JList to make a "striking" difference // between separators and other components... label.setForeground( color ); label.setFont( label.getFont().deriveFont( Font.BOLD ) ); label.setHorizontalAlignment( SwingConstants.RIGHT ); setSeparatorProperty( label ); final JSeparator separator = new JSeparator(); // Apparently, on Mac OSX, the height of a separator is slightly different // than on other OSs... separator.setAlignmentY( HostUtils.getHostInfo().isMacOS() ? 0.25f : Component.CENTER_ALIGNMENT ); setSeparatorProperty( separator ); aContainer.add( label ); aContainer.add( separator ); return aContainer; }
/** * Stores the given analysis results to the given file as HTML. * * @param aSelectedFile * @param aAnalysisResult */ private void storeToHtmlFile( final File aSelectedFile, final Asm45DataSet aAnalysisResult ) { try { toHtmlPage( aSelectedFile, aAnalysisResult ); } catch ( final IOException exception ) { // Make sure to handle IO-interrupted exceptions properly! if ( !HostUtils.handleInterruptedException( exception ) ) { LOG.log( Level.WARNING, "HTML export failed!", exception ); } } }
/** * Stores the current acquisition data to the given file, in the OLS-data file * format. * * @param aFile * the file to write the data to, cannot be <code>null</code>. * @throws IOException * in case of errors during opening/writing to the file. */ public void saveDataFile( final File aFile ) throws IOException { final FileWriter writer = new FileWriter( aFile ); try { getCurrentProject().writeData( writer ); setStatusOnEDT( "Capture data saved to {0} ...", aFile.getName() ); } finally { HostUtils.closeResource( writer ); } }