All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.nuiton.jaxx.runtime.spi.init.ComponentInitializerSupport Maven / Gradle / Ivy

There is a newer version: 3.1.5
Show newest version
package org.nuiton.jaxx.runtime.spi.init;

/*-
 * #%L
 * JAXX :: Runtime Spi
 * %%
 * Copyright (C) 2008 - 2020 Code Lutin, Ultreia.io
 * %%
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU Lesser General Public License as
 * published by the Free Software Foundation, either version 3 of the
 * License, or (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Lesser Public License for more details.
 *
 * You should have received a copy of the GNU General Lesser Public
 * License along with this program.  If not, see
 * .
 * #L%
 */

import java.util.Map;
import java.util.TreeMap;
import javax.swing.JComponent;
import org.nuiton.jaxx.runtime.JAXXObject;

/**
 * Created by tchemit on 13/11/17.
 *
 * @author Tony Chemit - [email protected]
 * @deprecated will be removed when 3.0 will be released.
 */
@Deprecated
public abstract class ComponentInitializerSupport implements ComponentInitializer {

    private final Map editorMap = new TreeMap<>();
    private final Class componentType;
    private JAXXObject ui;

    protected ComponentInitializerSupport(Class componentType) {
        this.componentType = componentType;
    }

    @Override
    public boolean acceptComponent(Object component) {
        return componentType.isAssignableFrom(component.getClass());
    }

    @Override
    public boolean acceptUi(JAXXObject ui) {
        return true;
    }

    public void register(String name, C component) {
        editorMap.put(name, component);
    }

    @SuppressWarnings("unchecked")
    public void register(JComponent component) {
        editorMap.put(component.getName(), (C) component);
    }

    @Override
    public void start(JAXXObject ui) {
        this.ui = ui;
        editorMap.clear();
    }

    @Override
    public void reset() {
        editorMap.clear();
    }

    @Override
    public void end(JAXXObject ui) {
    }

    public boolean isTouched() {
        return ui != null && !editorMap.isEmpty();
    }

    public Map getEditorMap() {
        return editorMap;
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy