Package com.nexirius.jnex.example

Source Code of com.nexirius.jnex.example.JnexExample

package com.nexirius.jnex.example;

import java.net.URL;
import java.awt.*;
import javax.swing.*;

import com.nexirius.framework.datamodel.*;
import com.nexirius.framework.dataeditor.*;
import com.nexirius.framework.dataviewer.*;
import com.nexirius.framework.layout.*;
import com.nexirius.framework.swing.SwingViewerCreator;

import com.nexirius.jnex.example.datamodel.ExampleModel;
import com.nexirius.jnex.example.layout.*;
import com.nexirius.jnex.example.dataeditor.*;

import com.nexirius.util.support.CurrencyManager;

import com.nexirius.framework.datacontroller.*;
import com.nexirius.framework.application.Application;
import com.nexirius.framework.application.DialogManager;

public class JnexExample extends Application
{
    private ExampleModel exampleModel;

    public JnexExample(String[] argv)
  {
        super(argv);
  }

    public void preInit() {
        CurrencyManager.init(getFactory().getClientResource());
        exampleModel = new ExampleModel();
        getApplicationModel().appendMethod(new DefaultDataModelCommand("Exit") {
            public void doAction() {
                exit();
            }
        });
    }

  public void init()
  {
    ViewerCreatorMap map = getFactory().getViewerCreatorMap();

    map.register("com.nexirius.jnex.example.datamodel.ExampleModel", new ExampleLayout(), true);
    map.register("com.nexirius.jnex.example.datamodel.ProductModel", new ProductEditorCreator());
    map.register("com.nexirius.jnex.example.datamodel.FeatureArrayModel", new FeatureTableLayout(), false);

    try {
            DataViewer viewer = factory.createViewer(exampleModel, true);
      JScrollPane scrolled = new JScrollPane(viewer.getJComponent());
      getMainPanel().setLayout(new BorderLayout());
            getMainPanel().add(scrolled, BorderLayout.CENTER);
            getMainFrame().pack();
            DialogManager.center(getMainFrame(), true);
    }
    catch (Exception ex)
    {
      ex.printStackTrace();
    }
  }

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

    public DataModel getApplicationModel() {
        return exampleModel;
    }

  public static void main(String argv[])
  {
    String plaf = "com.sun.java.swing.plaf.windows.WindowsLookAndFeel";

    try
    {
      UIManager.setLookAndFeel(plaf);
    }
    catch (Exception e)
    {
      System.out.println("Can't set '" + plaf +"' look and feel");
    }

    try
    {
      new JnexExample(argv).run();
    }
    catch (Exception ex)
    {
      ex.printStackTrace();
    }
  }
}

TOP

Related Classes of com.nexirius.jnex.example.JnexExample

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.