Package com.nexirius.multimail.dataviewer

Source Code of com.nexirius.multimail.dataviewer.ImportArrayEditor

package com.nexirius.multimail.dataviewer;

import com.nexirius.framework.dataviewer.ViewerFactory;
import com.nexirius.framework.dataviewer.ProgressViewerCreator;
import com.nexirius.framework.datamodel.DataModel;
import com.nexirius.framework.gadgets.ArrayLayout;
import com.nexirius.framework.swing.SwingViewer;
import com.nexirius.framework.swing.CFJLabel;
import com.nexirius.multimail.datamodel.ImportArrayModel;

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

public class ImportArrayEditor implements SwingViewer {
    private ImportArrayModel importArrayModel;

    public JComponent createJComponent(ViewerFactory factory) {
        JPanel panel = new JPanel();
        panel.setLayout(new ArrayLayout(false, ArrayLayout.FULL_SIZE));

        try {
            panel.add(createFieldEditor(ImportArrayModel.FIELD_excelFileName, factory));
            panel.add(createFieldEditor(ImportArrayModel.FIELD_mapping, factory));
            panel.add(createFieldEditor(ImportArrayModel.FIELD_importCounter, factory));
            panel.add(factory.createViewer(new ProgressViewerCreator(), getDataModel().getChild(ImportArrayModel.FIELD_progress)).getJComponent());
            panel.add(factory.createViewer(new ProgressViewerCreator(), getDataModel().getChild(ImportArrayModel.FIELD_stopped)).getJComponent());
        } catch (Exception e) {
            e.printStackTrace()//To change body of catch statement use File | Settings | File Templates.
        }

        return panel;
    }

    public boolean isEditor() {
        return true;
    }

    private Component createFieldEditor(String field, ViewerFactory factory) {
        JPanel panel = new JPanel(new BorderLayout());

        CFJLabel cfjLabel = new CFJLabel(factory.getClientResource(), field);

        cfjLabel.setPreferredSize(new Dimension(Math.max(200, cfjLabel.getPreferredSize().width), cfjLabel.getPreferredSize().height));
        panel.add(cfjLabel, BorderLayout.WEST);
        try {
            panel.add(factory.createDefaultEditor(getDataModel().getChild(field)).getJComponent(), BorderLayout.CENTER);
        } catch (Exception e) {
            e.printStackTrace()//To change body of catch statement use File | Settings | File Templates.
        }

        return panel;
    }

    public void setDataModel(DataModel model) {
        importArrayModel = (ImportArrayModel)model;
    }

    public DataModel getDataModel() {
        return importArrayModel;
    }
}
TOP

Related Classes of com.nexirius.multimail.dataviewer.ImportArrayEditor

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.