//{HEADER
/**
* This class is part of jnex 'Nexirius Application Framework for Java'
*
* Source File Date: Mon Feb 16 16:56:00 GMT+01:00 2004
* @version: 2.8 (Wed Feb 18 07:27:51 GMT+01:00 2004)
* Class name: com.nexirius.com.nexirius.multimail.dataviewer.MainViewer
*
* Copyright (C) Nexirius GmbH, CH-4450 Sissach, Switzerland (www.nexirius.ch)
*
* <p>This library is free software; you can redistribute it and/or<br>
* modify it under the terms of the GNU Lesser General Public<br>
* License as published by the Free Software Foundation; either<br>
* version 2.1 of the License, or (at your option) any later version.</p>
*
* <p>This library is distributed in the hope that it will be useful,<br>
* but WITHOUT ANY WARRANTY; without even the implied warranty of<br>
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU<br>
* Lesser General Public License for more details.</p>
*
* <p>You should have received a copy of the GNU Lesser General Public<br>
* License along with this library; if not, write to the Free Software<br>
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA</p>
* </blockquote>
*
* <p>
* Nexirius GmbH, hereby disclaims all copyright interest in<br>
* the library jnex' 'Nexirius Application Framework for Java' written<br>
* by Marcel Baumann.</p>
*/
//}HEADER
package com.nexirius.multimail.dataviewer;
import java.awt.*;
import java.awt.event.KeyListener;
import java.awt.event.KeyEvent;
import javax.swing.*;
import javax.swing.border.EmptyBorder;
import com.nexirius.framework.datamodel.DataModel;
import com.nexirius.framework.dataviewer.ViewerFactory;
import com.nexirius.framework.gadgets.ArrayLayout;
import com.nexirius.framework.gadgets.JPanelWithBackgroundImage;
import com.nexirius.framework.swing.SwingViewerCreator;
import com.nexirius.multimail.datamodel.MainModel;
import com.nexirius.multimail.datamodel.ListSortingModel;
import com.nexirius.multimail.datamodel.MailListModel;
public class MainViewer extends StandardViewer {
public static final String _NEXIRIUS_VERSION = "2.8";
MainModel mainModel;
public MainViewer()
{
}
public JComponent createJComponent(ViewerFactory factory) {
setLayout(new BorderLayout());
try {
JPanel north = new JPanel();
north.setLayout(new ArrayLayout(false, ArrayLayout.FULL_SIZE));
JLabel label = (JLabel) factory.createDefaultViewer(mainModel.getChild(MainModel.FIELD_LICENSE_TEXT)).getJComponent();
label.setFont(new Font("Helvetica", Font.PLAIN, 20));
label.setForeground(Color.white);
label.setOpaque(false);
label.setHorizontalAlignment(JLabel.CENTER);
JPanel panel = new JPanelWithBackgroundImage(factory.getClientResource(), "jnexBackground");
panel.setBorder(new EmptyBorder(10, 10, 10, 10));
panel.setLayout(new GridLayout(1, 1));
panel.add(label);
north.add(panel);
north.add(createFieldEditor("smtp", factory));
north.add(createFieldEditor("smtpUser", factory));
north.add(createFieldEditor("smtpPassword", factory));
north.add(createFieldEditor("from", factory));
north.add(createFieldEditor("subject", factory));
north.add(createFieldEditor("sendAll", factory));
north.add(createFieldEditor("html", factory));
north.add(createFieldEditor(ListSortingModel.FIELD_NAME + ';' + ListSortingModel.FIELD_orderBy, factory));
add(north, BorderLayout.NORTH);
JSplitPane center = new JSplitPane(JSplitPane.VERTICAL_SPLIT);
JComponent textViewer = factory.createViewer(new SwingViewerCreator(TextViewer.class), mainModel).getJComponent();
JComponent listViewer = factory.createDefaultEditor(mainModel.getViewableChild("MailList")).getJComponent();
textViewer.setPreferredSize(new Dimension(1000, 300));
listViewer.setPreferredSize(new Dimension(1000, 300));
center.setLeftComponent(textViewer);
center.setRightComponent(listViewer);
center.setDividerLocation(0.5);
add(center, BorderLayout.CENTER);
// add(createFieldEditor("progress", factory), BorderLayout.SOUTH);
// setPreferredSize(new Dimension(1000, 800));
listViewer.addKeyListener(new KeyListener() {
public void keyTyped(KeyEvent e) {
if (e.getKeyCode() != KeyEvent.VK_DELETE && e.getKeyCode() != KeyEvent.VK_BACK_SPACE) {
return;
}
try {
((MailListModel) mainModel.getChild("MailList")).doDeleteEntry();
} catch (Exception e1) {
e1.printStackTrace();
}
}
public void keyPressed(KeyEvent e) {
//TODO
}
public void keyReleased(KeyEvent e) {
//TODO
}
});
} catch (Exception ex)
{
ex.printStackTrace();
}
return this;
}
public boolean isEditor() {
return true;
}
public void setDataModel(DataModel model) {
this.mainModel = (MainModel)model;
}
public DataModel getDataModel() {
return mainModel;
}
}