Example usage for java.nio.file Path toAbsolutePath

List of usage examples for java.nio.file Path toAbsolutePath

Introduction

In this page you can find the example usage for java.nio.file Path toAbsolutePath.

Prototype

Path toAbsolutePath();

Source Link

Document

Returns a Path object representing the absolute path of this path.

Usage

From source file:org.finra.herd.dao.Log4jOverridableConfigurerTest.java

/**
 * Reads the contents of the resource location, substitutes the filename token (if it exists), and inserts the contents of the resource to the database.
 *
 * @param resourceLocation the resource location of the Log4J configuration.
 * @param monitorInterval the monitor interval in seconds to use when writing the configuration file to the database.
 * @param outputPath the Log4J output path.
 * @param log4jConfigurationColumn the column name for the Log4J configuration column
 * @param configEntityKey the configuration entity key.
 *
 * @throws Exception if the file contents couldn't be read or the database record couldn't be inserted.
 *//* ww  w  .  j  av  a2 s.  c  o m*/
private void insertDbLog4JConfigurationFromResourceLocation(String resourceLocation, int monitorInterval,
        Path outputPath, String log4jConfigurationColumn, String configEntityKey) throws Exception {
    // Get the Log4J configuration contents from the classpath file.
    String log4JFileContents = IOUtils.toString(resourceLoader.getResource(resourceLocation).getInputStream());

    // Change the tokenized output filename (if it exists) and replace it with a random filename to support multiple invocations of the JUnit.
    log4JFileContents = log4JFileContents.replace(LOG4J_FILENAME_TOKEN,
            outputPath.toAbsolutePath().toString().replace("\\", "/"));

    // Change the monitor interval.
    log4JFileContents = log4JFileContents.replace("monitorInterval=\"0\"",
            "monitorInterval=\"" + String.valueOf(monitorInterval) + "\"");

    // Insert the data.
    String sql = String.format("INSERT INTO %s (%s, %s) VALUES (?,?)", ConfigurationEntity.TABLE_NAME,
            ConfigurationEntity.COLUMN_KEY, log4jConfigurationColumn);
    executePreparedStatement(sql, configEntityKey, log4JFileContents);
}

From source file:org.apache.tika.eval.AbstractProfiler.java

protected EvalFilePaths getPathsFromSrcCrawl(Metadata metadata, Path srcDir, Path extracts) {
    Path relativeSourceFilePath = Paths.get(metadata.get(FSProperties.FS_REL_PATH));
    Path extractFile = findFile(extracts, relativeSourceFilePath);
    Path inputFile = srcDir.resolve(relativeSourceFilePath);
    long srcLen = -1l;
    //try to get the length of the source file in case there was an error
    //in both extracts
    try {/*  w w w . java  2  s  . c  om*/
        srcLen = Files.size(inputFile);
    } catch (IOException e) {
        LOG.warn("Couldn't get length for: {}", inputFile.toAbsolutePath());
    }
    return new EvalFilePaths(relativeSourceFilePath, extractFile, srcLen);
}

From source file:org.craftercms.studio.impl.v1.repository.git.GitContentRepositoryHelper.java

public Repository createGitRepository(Path path) {
    Repository toReturn;//from   w  w w .j  a va 2  s  . c  om
    path = Paths.get(path.toAbsolutePath().toString(), GIT_ROOT);
    try {
        toReturn = FileRepositoryBuilder.create(path.toFile());
        toReturn.create();

        toReturn = optimizeRepository(toReturn);
        try (Git git = new Git(toReturn)) {
            git.commit().setAllowEmpty(true).setMessage("Create new repository.").call();
        } catch (GitAPIException e) {
            logger.error("Error while creating repository for site with path" + path.toString(), e);
            toReturn = null;
        }
    } catch (IOException e) {
        logger.error("Error while creating repository for site with path" + path.toString(), e);
        toReturn = null;
    }

    return toReturn;
}

From source file:org.esa.s2tbx.dataio.s2.Sentinel2ProductReader.java

/**
 * From a granule path, search a jpeg file for the given resolution, extract tile layout
 * information and update/*from w  ww. ja va 2  s  .co  m*/
 *
 * @param granuleMetadataPath the complete path to the granule directory
 * @param resolution          the resolution for which we wan to find the tile layout
 * @return the tile layout for the resolution, or {@code null} if none was found
 */
private TileLayout retrieveTileLayoutFromGranuleDirectory(Path granuleMetadataPath,
        S2SpatialResolution resolution) {
    TileLayout tileLayoutForResolution = null;

    Path pathToImages = granuleMetadataPath.resolve("IMG_DATA");

    try {

        for (Path imageFilePath : getImageDirectories(pathToImages, resolution)) {
            try {
                tileLayoutForResolution = OpenJpegUtils.getTileLayoutWithOpenJPEG(S2Config.OPJ_INFO_EXE,
                        imageFilePath);
                if (tileLayoutForResolution != null) {
                    break;
                }
            } catch (IOException | InterruptedException e) {
                // if we have an exception, we try with the next file (if any)
                // and log a warning
                SystemUtils.LOG.warning("Could not retrieve tile layout for file "
                        + imageFilePath.toAbsolutePath().toString() + " error returned: " + e.getMessage());
            }
        }
    } catch (IOException e) {
        SystemUtils.LOG.warning("Could not retrieve tile layout for granule "
                + granuleMetadataPath.toAbsolutePath().toString() + " error returned: " + e.getMessage());
    }

    return tileLayoutForResolution;
}

From source file:org.tinymediamanager.core.tvshow.TvShowList.java

/**
 * Gets the TV show by path.//w w w .j  av a  2s  .c  o  m
 * 
 * @param path
 *          path
 * @return the TV show by path
 */
public TvShow getTvShowByPath(Path path) {
    ArrayList<TvShow> tvShows = new ArrayList<>(tvShowList);
    // iterate over all tv shows and check whether this path is being owned by one
    for (TvShow tvShow : tvShows) {
        if (tvShow.getPathNIO().compareTo(path.toAbsolutePath()) == 0) {
            return tvShow;
        }
    }

    return null;
}

From source file:org.opencb.cellbase.app.transform.VariationParser.java

private void gunzipFileIfNeeded(Path directory, String fileName) throws IOException, InterruptedException {
    Path zippedFile = directory.resolve(fileName + ".gz");
    if (Files.exists(zippedFile)) {
        logger.info("Unzipping " + zippedFile + "...");
        Process process = Runtime.getRuntime().exec("gunzip " + zippedFile.toAbsolutePath());
        process.waitFor();/* ww w  .j  a v a  2 s  . c  om*/
    } else {
        Path unzippedFile = directory.resolve(fileName);
        if (Files.exists(unzippedFile)) {
            logger.info(
                    "File " + unzippedFile + " was previously unzipped: skipping 'gunzip' for this file ...");
        } else {
            throw new FileNotFoundException("File " + zippedFile + " doesn't exist");
        }
    }
}

From source file:com.bytelightning.opensource.pokerface.PokerFace.java

/**
 * Load the specified JavaScript library into the global scope of the Nashorn engine
 * @param lib   Path to the JavaScript library.
 */// www  . jav  a 2 s. c o  m
protected boolean loadScriptLibrary(Path lib) {
    try (Reader r = Files.newBufferedReader(lib, Charset.forName("utf-8"))) {
        Nashorn.eval(r, Nashorn.getBindings(ScriptContext.GLOBAL_SCOPE));
    } catch (Exception e) {
        Logger.error("Unable to load JavaScript library " + lib.toAbsolutePath().toString(), e);
        return false;
    }
    return true;
}

From source file:org.tinymediamanager.ui.settings.GeneralSettingsPanel.java

/**
 * Instantiates a new general settings panel.
 *///from  w  w  w  .j a v  a 2  s.c o m
public GeneralSettingsPanel() {
    setLayout(new FormLayout(
            new ColumnSpec[] { FormSpecs.RELATED_GAP_COLSPEC, ColumnSpec.decode("left:max(200px;min):grow"),
                    FormSpecs.RELATED_GAP_COLSPEC, ColumnSpec.decode("max(200px;default):grow"),
                    FormSpecs.RELATED_GAP_COLSPEC, },
            new RowSpec[] { FormSpecs.RELATED_GAP_ROWSPEC, FormSpecs.DEFAULT_ROWSPEC,
                    FormSpecs.RELATED_GAP_ROWSPEC, FormSpecs.DEFAULT_ROWSPEC, FormSpecs.RELATED_GAP_ROWSPEC,
                    FormSpecs.DEFAULT_ROWSPEC, FormSpecs.RELATED_GAP_ROWSPEC, FormSpecs.DEFAULT_ROWSPEC,
                    FormSpecs.RELATED_GAP_ROWSPEC, }));

    JPanel panelUI = new JPanel();
    panelUI.setBorder(new TitledBorder(null, BUNDLE.getString("Settings.ui"), TitledBorder.LEADING, //$NON-NLS-1$
            TitledBorder.TOP, null, null));
    add(panelUI, "2, 2, 3, 1, fill, fill");
    panelUI.setLayout(new FormLayout(
            new ColumnSpec[] { FormSpecs.RELATED_GAP_COLSPEC, FormSpecs.DEFAULT_COLSPEC,
                    FormSpecs.RELATED_GAP_COLSPEC, ColumnSpec.decode("100dlu"), FormSpecs.RELATED_GAP_COLSPEC,
                    ColumnSpec.decode("default:grow"), FormSpecs.UNRELATED_GAP_COLSPEC,
                    FormSpecs.DEFAULT_COLSPEC, FormSpecs.UNRELATED_GAP_COLSPEC, FormSpecs.DEFAULT_COLSPEC,
                    FormSpecs.RELATED_GAP_COLSPEC, FormSpecs.DEFAULT_COLSPEC, FormSpecs.RELATED_GAP_COLSPEC,
                    ColumnSpec.decode("default:grow"), FormSpecs.RELATED_GAP_COLSPEC, },
            new RowSpec[] { FormSpecs.RELATED_GAP_ROWSPEC, FormSpecs.DEFAULT_ROWSPEC,
                    FormSpecs.RELATED_GAP_ROWSPEC, FormSpecs.DEFAULT_ROWSPEC, FormSpecs.RELATED_GAP_ROWSPEC,
                    FormSpecs.DEFAULT_ROWSPEC, FormSpecs.RELATED_GAP_ROWSPEC, FormSpecs.DEFAULT_ROWSPEC,
                    FormSpecs.RELATED_GAP_ROWSPEC, }));
    LocaleComboBox actualLocale = null;
    // cbLanguage = new JComboBox(Utils.getLanguages().toArray());
    Locale settingsLang = Utils.getLocaleFromLanguage(Globals.settings.getLanguage());
    for (Locale l : Utils.getLanguages()) {
        LocaleComboBox localeComboBox = new LocaleComboBox(l);
        locales.add(localeComboBox);
        if (l.equals(settingsLang)) {
            actualLocale = localeComboBox;
        }
    }

    JLabel lblUiLanguage = new JLabel(BUNDLE.getString("Settings.language"));
    panelUI.add(lblUiLanguage, "2, 2");
    cbLanguage = new JComboBox(locales.toArray());
    panelUI.add(cbLanguage, "4, 2");

    if (actualLocale != null) {
        cbLanguage.setSelectedItem(actualLocale);
    }

    JSeparator separator = new JSeparator();
    separator.setOrientation(SwingConstants.VERTICAL);
    panelUI.add(separator, "8, 2, 1, 7");

    JLabel lblFontFamily = new JLabel(BUNDLE.getString("Settings.fontfamily")); //$NON-NLS-1$
    panelUI.add(lblFontFamily, "10, 2, right, default");
    GraphicsEnvironment env = GraphicsEnvironment.getLocalGraphicsEnvironment();
    cbFontFamily = new JComboBox(env.getAvailableFontFamilyNames());
    cbFontFamily.setSelectedItem(Globals.settings.getFontFamily());
    int index = cbFontFamily.getSelectedIndex();
    if (index < 0) {
        cbFontFamily.setSelectedItem("Dialog");
        index = cbFontFamily.getSelectedIndex();
    }
    if (index < 0) {
        cbFontFamily.setSelectedIndex(0);
    }
    panelUI.add(cbFontFamily, "12, 2, fill, default");

    JLabel lblFontSize = new JLabel(BUNDLE.getString("Settings.fontsize")); //$NON-NLS-1$
    panelUI.add(lblFontSize, "10, 4, right, default");

    cbFontSize = new JComboBox(DEFAULT_FONT_SIZES);
    cbFontSize.setSelectedItem(Globals.settings.getFontSize());
    index = cbFontSize.getSelectedIndex();
    if (index < 0) {
        cbFontSize.setSelectedIndex(0);
    }

    panelUI.add(cbFontSize, "12, 4, fill, default");

    JPanel panel = new JPanel();
    panelUI.add(panel, "2, 6, 5, 1, fill, fill");
    panel.setLayout(new FormLayout(new ColumnSpec[] { FormSpecs.DEFAULT_COLSPEC, FormSpecs.RELATED_GAP_COLSPEC,
            ColumnSpec.decode("100dlu"), FormSpecs.RELATED_GAP_COLSPEC, ColumnSpec.decode("default:grow"), },
            new RowSpec[] { FormSpecs.DEFAULT_ROWSPEC, FormSpecs.LABEL_COMPONENT_GAP_ROWSPEC,
                    FormSpecs.DEFAULT_ROWSPEC, }));

    JLabel lblMissingTranslation = new JLabel(BUNDLE.getString("tmm.helptranslate"));
    panel.add(lblMissingTranslation, "1, 1, 5, 1");

    lblLinkTransifex = new LinkLabel("https://www.transifex.com/projects/p/tinymediamanager/");
    panel.add(lblLinkTransifex, "1, 3, 5, 1");
    lblLinkTransifex.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent arg0) {
            try {
                TmmUIHelper.browseUrl(lblLinkTransifex.getNormalText());
            } catch (Exception e) {
                LOGGER.error(e.getMessage());
                MessageManager.instance
                        .pushMessage(new Message(MessageLevel.ERROR, lblLinkTransifex.getNormalText(),
                                "message.erroropenurl", new String[] { ":", e.getLocalizedMessage() }));//$NON-NLS-2$
            }
        }
    });

    tpFontHint = new JTextPane();
    tpFontHint.setOpaque(false);
    TmmFontHelper.changeFont(tpFontHint, 0.833);
    tpFontHint.setText(BUNDLE.getString("Settings.fonts.hint")); //$NON-NLS-1$
    panelUI.add(tpFontHint, "10, 6, 5, 1");

    lblLanguageHint = new JLabel("");
    TmmFontHelper.changeFont(lblLanguageHint, Font.BOLD);
    panelUI.add(lblLanguageHint, "2, 8, 5, 1");

    lblFontChangeHint = new JLabel("");
    TmmFontHelper.changeFont(lblFontChangeHint, Font.BOLD);
    panelUI.add(lblFontChangeHint, "10, 8, 5, 1");

    JPanel panelMemory = new JPanel();
    panelMemory.setBorder(new TitledBorder(null, BUNDLE.getString("Settings.memoryborder"), //$NON-NLS-1$
            TitledBorder.LEADING, TitledBorder.TOP, null, null));
    add(panelMemory, "2, 4, fill, fill");
    panelMemory.setLayout(new FormLayout(
            new ColumnSpec[] { FormFactory.RELATED_GAP_COLSPEC, FormFactory.DEFAULT_COLSPEC,
                    FormFactory.RELATED_GAP_COLSPEC, ColumnSpec.decode("250px:grow(4)"),
                    FormFactory.RELATED_GAP_COLSPEC, ColumnSpec.decode("max(20dlu;default)"),
                    ColumnSpec.decode("left:default:grow(5)"), },
            new RowSpec[] { FormFactory.DEFAULT_ROWSPEC, FormFactory.RELATED_GAP_ROWSPEC,
                    RowSpec.decode("default:grow"), FormFactory.RELATED_GAP_ROWSPEC, }));

    JLabel lblMemoryT = new JLabel(BUNDLE.getString("Settings.memory")); //$NON-NLS-1$
    panelMemory.add(lblMemoryT, "2, 1");

    sliderMemory = new JSlider();
    sliderMemory.setPaintLabels(true);
    sliderMemory.setPaintTicks(true);
    sliderMemory.setSnapToTicks(true);
    sliderMemory.setMajorTickSpacing(512);
    sliderMemory.setMinorTickSpacing(128);
    sliderMemory.setMinimum(256);
    sliderMemory.setMaximum(1536);
    sliderMemory.setValue(512);
    panelMemory.add(sliderMemory, "4, 1, fill, default");

    lblMemory = new JLabel("512"); //$NON-NLS-1$
    panelMemory.add(lblMemory, "6, 1, right, default");

    JLabel lblMb = new JLabel("MB");
    panelMemory.add(lblMb, "7, 1, left, default");

    tpMemoryHint = new JTextPane();
    tpMemoryHint.setOpaque(false);
    tpMemoryHint.setText(BUNDLE.getString("Settings.memory.hint")); //$NON-NLS-1$
    TmmFontHelper.changeFont(tpMemoryHint, 0.833);
    panelMemory.add(tpMemoryHint, "2, 3, 6, 1, fill, fill");

    JPanel panelProxySettings = new JPanel();
    panelProxySettings.setBorder(new TitledBorder(null, BUNDLE.getString("Settings.proxy"), //$NON-NLS-1$
            TitledBorder.LEADING, TitledBorder.TOP, null, null));
    add(panelProxySettings, "4, 4, fill, fill");
    panelProxySettings.setLayout(new FormLayout(
            new ColumnSpec[] { FormFactory.RELATED_GAP_COLSPEC, FormFactory.DEFAULT_COLSPEC,
                    FormFactory.RELATED_GAP_COLSPEC, ColumnSpec.decode("default:grow"), },
            new RowSpec[] { FormFactory.RELATED_GAP_ROWSPEC, FormFactory.DEFAULT_ROWSPEC,
                    FormFactory.RELATED_GAP_ROWSPEC, FormFactory.DEFAULT_ROWSPEC,
                    FormFactory.RELATED_GAP_ROWSPEC, FormFactory.DEFAULT_ROWSPEC,
                    FormFactory.RELATED_GAP_ROWSPEC, FormFactory.DEFAULT_ROWSPEC,
                    FormFactory.RELATED_GAP_ROWSPEC, }));

    JLabel lblProxyHost = new JLabel(BUNDLE.getString("Settings.proxyhost")); //$NON-NLS-1$
    panelProxySettings.add(lblProxyHost, "2, 2, right, default");

    tfProxyHost = new JTextField();
    lblProxyHost.setLabelFor(tfProxyHost);
    panelProxySettings.add(tfProxyHost, "4, 2, fill, default");
    tfProxyHost.setColumns(10);

    JLabel lblProxyPort = new JLabel(BUNDLE.getString("Settings.proxyport")); //$NON-NLS-1$
    panelProxySettings.add(lblProxyPort, "2, 4, right, default");

    tfProxyPort = new JTextField();
    lblProxyPort.setLabelFor(tfProxyPort);
    panelProxySettings.add(tfProxyPort, "4, 4, fill, default");
    tfProxyPort.setColumns(10);

    JLabel lblProxyUser = new JLabel(BUNDLE.getString("Settings.proxyuser")); //$NON-NLS-1$
    panelProxySettings.add(lblProxyUser, "2, 6, right, default");

    tfProxyUsername = new JTextField();
    lblProxyUser.setLabelFor(tfProxyUsername);
    panelProxySettings.add(tfProxyUsername, "4, 6, fill, default");
    tfProxyUsername.setColumns(10);

    JLabel lblProxyPassword = new JLabel(BUNDLE.getString("Settings.proxypass")); //$NON-NLS-1$
    panelProxySettings.add(lblProxyPassword, "2, 8, right, default");

    tfProxyPassword = new JPasswordField();
    lblProxyPassword.setLabelFor(tfProxyPassword);
    panelProxySettings.add(tfProxyPassword, "4, 8, fill, default");

    JPanel panelMediaPlayer = new JPanel();
    panelMediaPlayer.setBorder(
            new TitledBorder(null, "MediaPlayer", TitledBorder.LEADING, TitledBorder.TOP, null, null));
    add(panelMediaPlayer, "2, 6, fill, fill");
    panelMediaPlayer.setLayout(new FormLayout(
            new ColumnSpec[] { FormSpecs.RELATED_GAP_COLSPEC, ColumnSpec.decode("default:grow"),
                    FormSpecs.RELATED_GAP_COLSPEC, FormSpecs.DEFAULT_COLSPEC, FormSpecs.RELATED_GAP_COLSPEC, },
            new RowSpec[] { FormSpecs.RELATED_GAP_ROWSPEC, FormSpecs.DEFAULT_ROWSPEC,
                    FormSpecs.RELATED_GAP_ROWSPEC, FormSpecs.DEFAULT_ROWSPEC,
                    FormSpecs.RELATED_GAP_ROWSPEC, }));

    tpMediaPlayer = new JTextPane();
    tpMediaPlayer.setOpaque(false);
    TmmFontHelper.changeFont(tpMediaPlayer, 0.833);
    tpMediaPlayer.setText(BUNDLE.getString("Settings.mediaplayer.hint")); //$NON-NLS-1$
    panelMediaPlayer.add(tpMediaPlayer, "2, 2, 3, 1, fill, fill");

    tfMediaPlayer = new JTextField();
    panelMediaPlayer.add(tfMediaPlayer, "2, 4, fill, default");
    tfMediaPlayer.setColumns(10);

    btnSearchMediaPlayer = new JButton(BUNDLE.getString("Button.chooseplayer")); //$NON-NLS-1$
    btnSearchMediaPlayer.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent arg0) {
            Path file = TmmUIHelper.selectFile(BUNDLE.getString("Button.chooseplayer")); //$NON-NLS-1$
            if (file != null && Utils.isRegularFile(file) || Platform.isMac()) {
                tfMediaPlayer.setText(file.toAbsolutePath().toString());
            }
        }
    });
    panelMediaPlayer.add(btnSearchMediaPlayer, "4, 4");

    JPanel panelCache = new JPanel();
    panelCache.setBorder(new TitledBorder(null, BUNDLE.getString("Settings.cache"), TitledBorder.LEADING, //$NON-NLS-1$
            TitledBorder.TOP, null, null));
    add(panelCache, "4, 6, fill, fill");
    panelCache.setLayout(new FormLayout(
            new ColumnSpec[] { FormSpecs.RELATED_GAP_COLSPEC, FormSpecs.DEFAULT_COLSPEC,
                    FormSpecs.RELATED_GAP_COLSPEC, ColumnSpec.decode("default:grow"),
                    FormSpecs.RELATED_GAP_COLSPEC, },
            new RowSpec[] { FormSpecs.RELATED_GAP_ROWSPEC, FormSpecs.DEFAULT_ROWSPEC,
                    FormSpecs.RELATED_GAP_ROWSPEC, FormSpecs.DEFAULT_ROWSPEC,
                    FormSpecs.RELATED_GAP_ROWSPEC, }));

    chckbxImageCache = new JCheckBox(BUNDLE.getString("Settings.imagecache"));//$NON-NLS-1$
    panelCache.add(chckbxImageCache, "2, 2, 3, 1");

    JLabel lblImageCacheQuality = new JLabel(BUNDLE.getString("Settings.imagecachetype"));//$NON-NLS-1$
    panelCache.add(lblImageCacheQuality, "2, 4, right, default");

    cbImageCacheQuality = new JComboBox(ImageCache.CacheType.values());
    panelCache.add(cbImageCacheQuality, "4, 4, fill, default");

    JPanel panelAnalytics = new JPanel();
    panelAnalytics.setBorder(new TitledBorder(null, BUNDLE.getString("Settings.analytics.border"), //$NON-NLS-1$
            TitledBorder.LEADING, TitledBorder.TOP, null, null));
    add(panelAnalytics, "2, 8, fill, fill");
    panelAnalytics.setLayout(new FormLayout(
            new ColumnSpec[] { FormSpecs.RELATED_GAP_COLSPEC, ColumnSpec.decode("default:grow"),
                    FormSpecs.RELATED_GAP_COLSPEC, },
            new RowSpec[] { FormSpecs.RELATED_GAP_ROWSPEC, FormSpecs.DEFAULT_ROWSPEC,
                    FormSpecs.RELATED_GAP_ROWSPEC, FormSpecs.DEFAULT_ROWSPEC, FormSpecs.LINE_GAP_ROWSPEC, }));

    chckbxAnalytics = new JCheckBox(BUNDLE.getString("Settings.analytics"));//$NON-NLS-1$
    panelAnalytics.add(chckbxAnalytics, "2, 2");

    JTextPane tpAnalyticsDescription = new JTextPane();
    tpAnalyticsDescription.setText(BUNDLE.getString("Settings.analytics.desc"));//$NON-NLS-1$
    tpAnalyticsDescription.setOpaque(false);
    panelAnalytics.add(tpAnalyticsDescription, "2, 4, fill, fill");

    JPanel panelMisc = new JPanel();
    panelMisc.setBorder(new TitledBorder(null, BUNDLE.getString("Settings.misc"), TitledBorder.LEADING, //$NON-NLS-1$
            TitledBorder.TOP, null, null));
    add(panelMisc, "4, 8, fill, fill");
    panelMisc.setLayout(new FormLayout(
            new ColumnSpec[] { FormFactory.RELATED_GAP_COLSPEC, FormFactory.DEFAULT_COLSPEC,
                    FormFactory.RELATED_GAP_COLSPEC, ColumnSpec.decode("default:grow"),
                    FormFactory.RELATED_GAP_COLSPEC, },
            new RowSpec[] { FormFactory.RELATED_GAP_ROWSPEC, FormFactory.DEFAULT_ROWSPEC,
                    FormFactory.RELATED_GAP_ROWSPEC, }));

    chckbxDeleteTrash = new JCheckBox(BUNDLE.getString("Settings.deletetrash"));
    panelMisc.add(chckbxDeleteTrash, "2, 2, 3, 1");

    initDataBindings();

    initMemorySlider();

    // listen to changes of the combo box
    ItemListener listener = new ItemListener() {
        public void itemStateChanged(ItemEvent e) {
            checkChanges();
        }
    };

    cbLanguage.addItemListener(listener);
    cbFontSize.addItemListener(listener);
    cbFontFamily.addItemListener(listener);
}

From source file:org.finra.dm.dao.Log4jOverridableConfigurerTest.java

@Test
public void testLog4JExistentOverrideLocation() throws Exception {
    Path configPath = getRandomLog4jConfigPath();
    Path outputPath = getRandomLog4jOutputPath();

    try {/*  w  ww  . j  av  a  2s .  c om*/
        // Write a Log4J configuration file that will create a random output file.
        writeFileFromResourceLocation(LOG4J_CONFIG_FILENAME, configPath, outputPath);

        Log4jOverridableConfigurer log4jConfigurer = new Log4jOverridableConfigurer();
        log4jConfigurer.setApplicationContext(applicationContext);
        log4jConfigurer
                .setDefaultResourceLocation(DaoEnvTestSpringModuleConfig.TEST_LOG4J_CONFIG_RESOURCE_LOCATION);
        log4jConfigurer.setOverrideResourceLocation(configPath.toAbsolutePath().toUri().toURL().toString());
        log4jConfigurer.setRefreshIntervalMillis(1000);
        log4jConfigurer.postProcessBeforeInitialization(null, null);

        // The override location does exist and should create a log file.
        assertTrue("Log4J output file doesn't exist, but should.", Files.exists(outputPath));
    } finally {
        cleanup(configPath, outputPath);
    }
}