package de.renew.draw.ui.impl.services;


import java.io.File;
import java.util.Properties;

import CH.ifa.draw.DrawPlugin;
import CH.ifa.draw.IOHelper;
import CH.ifa.draw.util.GUIProperties;
import de.renew.draw.ui.api.services.ApplicationService;

/**
 * Provides functionality for the {@link ApplicationService} interface.
 */
public class ApplicationServiceImpl implements ApplicationService {
    @Override
    public void setDrawProperties(Properties properties) {
        GUIProperties.setProperties(properties);
    }

    @Override
    public boolean isAvoidFrameReshape() {
        return GUIProperties.avoidFrameReshape();
    }

    @Override
    public boolean isNoGraphics() {
        return GUIProperties.noGraphics();
    }

    @Override
    public File getLastPath() {
        return IOHelper.getInstance().getLastPath();
    }

    @Override
    public boolean canClose() {
        return DrawPlugin.getGui().canClose();
    }

    @Override
    public void requestClose() {
        if (canClose()) {
            DrawPlugin.getGui().exit();
        }
    }

    @Override
    public void showStatus(String message) {
        DrawPlugin.getGui().showStatus(message);
    }


    @Override
    public void registerDrawingViewFactory(Class<?> key, String id) {
        DrawPlugin.getGui().registerDrawingViewFactoryID(key, id);
    }
}
