Search in sources :

Example 1 with IExternalFinderItemLoader

use of org.omegat.externalfinder.item.IExternalFinderItemLoader in project omegat by omegat-org.

the class ExternalFinder method getProjectConfig.

/**
 * Get the project-specific configuration.
 *
 * @return The configuration, or null if no project is loaded or the project
 *         has no config file
 */
public static ExternalFinderConfiguration getProjectConfig() {
    IProject currentProject = Core.getProject();
    if (!currentProject.isProjectLoaded()) {
        return null;
    }
    if (projectConfig == null) {
        // load project's xml file
        File projectFile = getProjectFile(currentProject);
        IExternalFinderItemLoader projectItemLoader = new ExternalFinderXMLLoader(projectFile, SCOPE.PROJECT);
        try {
            projectConfig = projectItemLoader.load();
        } catch (FileNotFoundException e) {
        // Ignore
        } catch (Exception e) {
            LOGGER.log(Level.SEVERE, e.getMessage(), e);
        }
    }
    return projectConfig;
}
Also used : IExternalFinderItemLoader(org.omegat.externalfinder.item.IExternalFinderItemLoader) FileNotFoundException(java.io.FileNotFoundException) File(java.io.File) IProject(org.omegat.core.data.IProject) ExternalFinderXMLLoader(org.omegat.externalfinder.item.ExternalFinderXMLLoader) FileNotFoundException(java.io.FileNotFoundException)

Example 2 with IExternalFinderItemLoader

use of org.omegat.externalfinder.item.IExternalFinderItemLoader in project omegat by omegat-org.

the class ExternalFinder method getGlobalConfig.

/**
 * Get the global configuration. This is stored in the user's OmegaT
 * configuration directory. If the file does not exist, an empty
 * configuration will be created and returned.
 *
 * @return The configuration (will never be null)
 */
public static ExternalFinderConfiguration getGlobalConfig() {
    if (globalConfig == null) {
        try {
            File globalFile = getGlobalConfigFile();
            IExternalFinderItemLoader userItemLoader = new ExternalFinderXMLLoader(globalFile, SCOPE.GLOBAL);
            globalConfig = userItemLoader.load();
        } catch (FileNotFoundException e) {
        // Ignore
        } catch (Exception e) {
            LOGGER.log(Level.SEVERE, e.getMessage(), e);
        }
        if (globalConfig == null) {
            globalConfig = ExternalFinderConfiguration.empty();
        }
    }
    return globalConfig;
}
Also used : IExternalFinderItemLoader(org.omegat.externalfinder.item.IExternalFinderItemLoader) FileNotFoundException(java.io.FileNotFoundException) File(java.io.File) ExternalFinderXMLLoader(org.omegat.externalfinder.item.ExternalFinderXMLLoader) FileNotFoundException(java.io.FileNotFoundException)

Aggregations

File (java.io.File)2 FileNotFoundException (java.io.FileNotFoundException)2 ExternalFinderXMLLoader (org.omegat.externalfinder.item.ExternalFinderXMLLoader)2 IExternalFinderItemLoader (org.omegat.externalfinder.item.IExternalFinderItemLoader)2 IProject (org.omegat.core.data.IProject)1