Package com.nexirius.ulc.example1

Source Code of com.nexirius.ulc.example1.ExampleUlcApplication

package com.nexirius.ulc.example1;

import com.nexirius.framework.datamodel.DataModel;
import com.nexirius.framework.datamodel.DefaultDataModelCommand;
import com.nexirius.ulc.application.ULCApplication;
import com.nexirius.ulc.example1.controller.ULCController;
import com.nexirius.ulc.example1.datamodel.ItemListModel;
import com.nexirius.ulc.example1.datamodel.ItemModel;
import com.nexirius.ulc.example1.dataviewer.ItemULCEditor;
import com.nexirius.ulc.example1.dataviewer.ItemListULCViewer;
import com.nexirius.ulc.example1.persistence.PersistenceManager;
import com.nexirius.ulc.ulcviewer.ULCViewer;
import com.nexirius.ulc.ulcviewer.ULCViewerCreator;
import com.nexirius.ulc.ulcviewer.ULCViewerFactory;
import com.ulcjava.base.application.ULCBoxPane;
import com.ulcjava.base.application.ULCComponent;
import com.ulcjava.base.development.DevelopmentRunner;

public class ExampleUlcApplication extends ULCApplication {
    ItemListModel mainModel;

    public String getApplicationName() {
        return "ExampleUlcApplication";
    }

    public void preInit() {
        mainModel = new ItemListModel();
        mainModel.appendMethod(new ExitCommand());
        mainModel.addDataModelListener(new ULCController(mainModel));
        PersistenceManager.init();
        try {
            mainModel.reloadCommand();
        } catch (Exception e) {
            e.printStackTrace()//TODO
        }
    }

    public void init() {
        try {
            ULCViewerFactory ulcFactory = getUlcFactory();

            //ulcFactory.getUlcViewerCreatorMap().register(ItemModel.class, new ULCViewerCreator(ItemULCEditor.class));
            ulcFactory.getUlcViewerCreatorMap().register(ItemListModel.class, new ULCViewerCreator(ItemListULCViewer.class));

            ULCViewer editor = ulcFactory.createDefaultUlcEditor(mainModel);
            ULCComponent ulcComponent = editor.getULCComponent(ulcFactory);

            getMainULCPanel().add(ULCBoxPane.BOX_EXPAND_EXPAND, ulcComponent);
        } catch (Exception e) {
            e.printStackTrace()//TODO
        }
    }

    public DataModel getApplicationModel() {
        return mainModel;
    }

    public void exit() {
        try {
            PersistenceManager.save(mainModel.getArray());
        } catch (Exception e) {
            e.printStackTrace();
        }
        super.exit();
    }

    public class ExitCommand extends DefaultDataModelCommand {
        public ExitCommand() {
            super("Exit");
        }

        public void doAction() {
            exit();
        }
    }

    public static void main(String[] argv) {
        DevelopmentRunner.setApplicationClass(ExampleUlcApplication.class);
        DevelopmentRunner.setUseGui(true);
        DevelopmentRunner.run();
    }
}
TOP

Related Classes of com.nexirius.ulc.example1.ExampleUlcApplication

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.
m/analytics.js','ga'); ga('create', 'UA-20639858-1', 'auto'); ga('send', 'pageview');