package de.germo.Testtool.gui;
import java.awt.BorderLayout;
import java.awt.Dimension;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.ComponentEvent;
import java.awt.event.ComponentListener;
import java.util.Observable;
import java.util.Observer;
import javax.swing.ImageIcon;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JMenu;
import javax.swing.JMenuBar;
import javax.swing.JMenuItem;
import javax.swing.JPanel;
import javax.swing.JRadioButtonMenuItem;
import javax.swing.JSeparator;
import javax.swing.JSplitPane;
import javax.swing.JToolBar;
import javax.swing.UIManager;
import de.germo.Testtool.models.TestToolModel;
/**
* @author MKI
* MainView (Hauptfenster) des TestTools
*/
public class MainView extends JFrame implements ActionListener, ComponentListener, Observer {
private JPanel jContentPane = null;
private JMenuBar jJMBMenuBar = null;
private JMenu jMFile = null;
private JMenuItem jMIOpen = null;
private JMenuItem jMIClose = null;
private JMenuItem jMISettings = null;
private JMenu jMEdit = null;
private JMenu jMView = null;
private JMenu jMHelp = null;
private JRadioButtonMenuItem jRBMISplit = null;
private JRadioButtonMenuItem jRBMITab = null;
private JMenuItem jMISearch = null;
private JMenuItem jMIHelp = null;
private JMenuItem jMIAbout = null;
private JToolBar jJToolBarBar = null;
private JPanel jPnlStatusBar = null;
private JPanel jPnlMainpanel = null;
private JButton jButton = null;
private JSplitPane jSplitPane = null;
private JSplitPane jSplitPane1 = null;
private JSplitPane jSplitPane2 = null;
private JPanel jPnlG21 = null;
private JPanel jPnlWin = null;
private JPanel jPnlDat = null;
private JSplitPane jSplitPane3 = null;
private JPanel jPnlWef = null;
private JPanel jPnlFill = null;
private JLabel jLblStatus = null;
/**
* This is the default constructor
*/
public MainView() {
super();
initialize();
addComponentListener(this);
setVisible(true);
resizeSplitPanes(768, 1024);
TestToolModel.getInstance().addObserver(this);
}
/**
* Resize der DividerLocator
* @param height neue Höhe
* @param width neue Breite
*/
private void resizeSplitPanes(int height, int width) {
width = getJSplitPane().getWidth();
height = getJSplitPane().getHeight();
int w1 = (int) (width / 2);
int w2 = (int) (width / 4);
getJSplitPane().setDividerLocation(w1);
getJSplitPane1().setDividerLocation(w2);
getJSplitPane2().setDividerLocation(w2);
getJSplitPane3().setDividerLocation((int )height / 2);
System.out.println("H:" + height + " : W:" + width);
System.out.println("w1:" + w1 + " : w2:" + w2);
}
/**
* This method initializes this
*
* @return void
*/
private void initialize() {
this.setContentPane(getJContentPane());
this.setJMenuBar(getJJMenuBar()); // Generated
this.setTitle("GERMO Testtool");
this.setBounds(0,0,1024,768); // Generated
this.setResizable(true);
this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
}
/**
* This method initializes jContentPane
*
* @return javax.swing.JPanel
*/
private JPanel getJContentPane() {
if (jContentPane == null) {
jContentPane = new JPanel();
jContentPane.setLayout(new BorderLayout());
jContentPane.add(getJJToolBarBar(), BorderLayout.NORTH); // Generated
jContentPane.add(getJPnlStatusBar(), BorderLayout.SOUTH); // Generated
jContentPane.add(getJPnlMainPanel(), BorderLayout.CENTER); // Generated
}
return jContentPane;
}
/**
* This method initializes jJMenuBar
*
* @return javax.swing.JMenuBar
*/
private JMenuBar getJJMenuBar() {
if (jJMBMenuBar == null) {
jJMBMenuBar = new JMenuBar();
jJMBMenuBar.add(getJMFile()); // Generated
jJMBMenuBar.add(getJMEdit()); // Generated
jJMBMenuBar.add(getJMView()); // Generated
jJMBMenuBar.add(getJMHelp()); // Generated
}
return jJMBMenuBar;
}
/**
* This method initializes jMenu
*
* @return javax.swing.JMenu
*/
private JMenu getJMFile() {
if (jMFile == null) {
jMFile = new JMenu();
jMFile.setText("Datei"); // Generated
jMFile.add(getJMIOpen()); // Generated
jMFile.add(getJMISettings()); // Generated
jMFile.add(new JSeparator());
jMFile.add(getJMIClose()); // Generated
}
return jMFile;
}
/**
* This method initializes jMenuItem
*
* @return javax.swing.JMenuItem
*/
private JMenuItem getJMIOpen() {
if (jMIOpen == null) {
jMIOpen = new JMenuItem();
jMIOpen.setText("Öffnen"); // Generated
jMIOpen.setActionCommand("open"); // Generated
jMIOpen.addActionListener(this);
}
return jMIOpen;
}
/**
* This method initializes jMenuItem
*
* @return javax.swing.JMenuItem
*/
private JMenuItem getJMIClose() {
if (jMIClose == null) {
jMIClose = new JMenuItem();
jMIClose.setText("Beenden"); // Generated
jMIClose.setActionCommand("quit"); // Generated
jMIClose.addActionListener(this);
}
return jMIClose;
}
/**
* This method initializes jMenuItem
*
* @return javax.swing.JMenuItem
*/
private JMenuItem getJMISettings() {
if (jMISettings == null) {
jMISettings = new JMenuItem();
jMISettings.setText("Einstellungen"); // Generated
jMISettings.setActionCommand("settings"); // Generated
}
return jMISettings;
}
/**
* This method initializes jMenu
*
* @return javax.swing.JMenu
*/
private JMenu getJMEdit() {
if (jMEdit == null) {
jMEdit = new JMenu();
jMEdit.setText("Bearbeiten"); // Generated
jMEdit.add(getJMISearch()); // Generated
}
return jMEdit;
}
/**
* This method initializes jMenu
*
* @return javax.swing.JMenu
*/
private JMenu getJMView() {
if (jMView == null) {
jMView = new JMenu();
jMView.setText("Ansicht"); // Generated
jMView.setEnabled(false); // Generated
jMView.add(getJRadioButtonMenuItem()); // Generated
jMView.add(getJRadioButtonMenuItem2()); // Generated
}
return jMView;
}
/**
* This method initializes jMenu
*
* @return javax.swing.JMenu
*/
private JMenu getJMHelp() {
if (jMHelp == null) {
jMHelp = new JMenu();
jMHelp.setText("Hilfe"); // Generated
jMHelp.add(getJMIHelp()); // Generated
jMHelp.add(getJMIAbout()); // Generated
}
return jMHelp;
}
/**
* This method initializes jRadioButtonMenuItem
*
* @return javax.swing.JRadioButtonMenuItem
*/
private JRadioButtonMenuItem getJRadioButtonMenuItem() {
if (jRBMISplit == null) {
jRBMISplit = new JRadioButtonMenuItem();
jRBMISplit.setText("Nebeneinander"); // Generated
jRBMISplit.setActionCommand("split"); // Generated
}
return jRBMISplit;
}
/**
* This method initializes jRadioButtonMenuItem
*
* @return javax.swing.JRadioButtonMenuItem
*/
private JRadioButtonMenuItem getJRadioButtonMenuItem2() {
if (jRBMITab == null) {
jRBMITab = new JRadioButtonMenuItem();
jRBMITab.setText("Tabs"); // Generated
jRBMITab.setActionCommand("tabbed"); // Generated
}
return jRBMITab;
}
/**
* This method initializes jMenuItem
*
* @return javax.swing.JMenuItem
*/
private JMenuItem getJMISearch() {
if (jMISearch == null) {
jMISearch = new JMenuItem();
jMISearch.setText("Suchen"); // Generated
jMISearch.setActionCommand("search"); // Generated
}
return jMISearch;
}
/**
* This method initializes jMenuItem
*
* @return javax.swing.JMenuItem
*/
private JMenuItem getJMIHelp() {
if (jMIHelp == null) {
jMIHelp = new JMenuItem();
jMIHelp.setText("Hilfe..."); // Generated
jMIHelp.setActionCommand("help"); // Generated
}
return jMIHelp;
}
/**
* This method initializes jMenuItem
*
* @return javax.swing.JMenuItem
*/
private JMenuItem getJMIAbout() {
if (jMIAbout == null) {
jMIAbout = new JMenuItem();
jMIAbout.setText("Über GERMO Testtool"); // Generated
jMIAbout.setActionCommand("about"); // Generated
}
return jMIAbout;
}
/**
* This method initializes jJToolBarBar
*
* @return javax.swing.JToolBar
*/
private JToolBar getJJToolBarBar() {
if (jJToolBarBar == null) {
jJToolBarBar = new JToolBar();
//jJToolBarBar.setBounds(new java.awt.Rectangle(0,0,1024,45)); // Generated
jJToolBarBar.setPreferredSize(new Dimension(1024,45));
jJToolBarBar.setFloatable(false); // Generated
jJToolBarBar.add(getJButton()); // Generated
}
return jJToolBarBar;
}
/**
* This method initializes jPanel
*
* @return javax.swing.JPanel
*/
private JPanel getJPnlStatusBar() {
if (jPnlStatusBar == null) {
jPnlStatusBar = new JPanel();
jPnlStatusBar.setLayout(null); // Generated
//jPnlStatusBar.setBounds(new java.awt.Rectangle(0,700,1024,21)); // Generated
jPnlStatusBar.setPreferredSize(new Dimension(1024,21));
jPnlStatusBar.setBorder(javax.swing.BorderFactory.createLineBorder(java.awt.Color.gray,1)); // Generated
jLblStatus = new JLabel();
jLblStatus.setBounds(4,0,500,21);
jLblStatus.setText("kein FileSet geöffnet");
jPnlStatusBar.add(jLblStatus, null);
}
return jPnlStatusBar;
}
/**
* This method initializes jPanel
*
* @return javax.swing.JPanel
*/
private JPanel getJPnlMainPanel() {
if (jPnlMainpanel == null) {
jPnlMainpanel = new JPanel();
jPnlMainpanel.setLayout(new BorderLayout()); // Generated
jPnlMainpanel.setPreferredSize(new Dimension(1024,655));
jPnlMainpanel.setBackground(new java.awt.Color(204,204,204)); // Generated
jPnlMainpanel.setBorder(javax.swing.BorderFactory.createLineBorder(java.awt.Color.gray,1)); // Generated
jPnlMainpanel.add(getJSplitPane(), BorderLayout.CENTER); // Generated
}
return jPnlMainpanel;
}
/**
* @see java.awt.event.ActionListener#actionPerformed(java.awt.event.ActionEvent)
*/
public void actionPerformed(ActionEvent e) {
if (e.getActionCommand().equals("quit")) {
this.dispose();
System.exit(0);
}
if (e.getActionCommand().equals("open")) {
FileSetChooserDialog fscd = new FileSetChooserDialog();
fscd.setVisible(true);
}
}
/**
* This method initializes jButton
*
* @return javax.swing.JButton
*/
private JButton getJButton() {
if (jButton == null) {
jButton = new JButton();
jButton.setIcon(new ImageIcon(getClass().getResource("/resource/open.gif"))); // Generated
jButton.setActionCommand("open");
jButton.addActionListener(this);
}
return jButton;
}
/**
* This method initializes jSplitPane
*
* @return javax.swing.JSplitPane
*/
private JSplitPane getJSplitPane() {
if (jSplitPane == null) {
jSplitPane = new JSplitPane();
//jSplitPane.setBounds(new java.awt.Rectangle(0,0,1024,655)); // Generated
jSplitPane.setPreferredSize(new Dimension(1024,655));
jSplitPane.setLeftComponent(getJSplitPane1()); // Generated
jSplitPane.setRightComponent(getJSplitPane2()); // Generated
}
return jSplitPane;
}
/**
* This method initializes jSplitPane1
*
* @return javax.swing.JSplitPane
*/
private JSplitPane getJSplitPane1() {
if (jSplitPane1 == null) {
jSplitPane1 = new JSplitPane();
jSplitPane1.setRightComponent(getJPnlWin()); // Generated
jSplitPane1.setLeftComponent(getJPanel3()); // Generated
}
return jSplitPane1;
}
/**
* This method initializes jSplitPane2
*
* @return javax.swing.JSplitPane
*/
private JSplitPane getJSplitPane2() {
if (jSplitPane2 == null) {
jSplitPane2 = new JSplitPane();
jSplitPane2.setRightComponent(getJSplitPane3()); // Generated
jSplitPane2.setLeftComponent(getJPnlDat()); // Generated
}
return jSplitPane2;
}
/**
* This method initializes jPanel
*
* @return javax.swing.JPanel
*/
private JPanel getJPanel3() {
if (jPnlG21 == null) {
jPnlG21 = new DataPanel("g21-Daten");
jPnlG21.setBackground(java.awt.Color.white); // Generated
}
return jPnlG21;
}
/**
* This method initializes jPanel1
*
* @return javax.swing.JPanel
*/
private JPanel getJPnlWin() {
if (jPnlWin == null) {
jPnlWin = new DataPanel("win-Daten");
jPnlWin.setBackground(java.awt.Color.white); // Generated
}
return jPnlWin;
}
/**
* This method initializes jPanel2
*
* @return javax.swing.JPanel
*/
private JPanel getJPnlDat() {
if (jPnlDat == null) {
jPnlDat = new DataPanel("dat-Daten");;
jPnlDat.setBackground(java.awt.Color.white); // Generated
}
return jPnlDat;
}
/**
* This method initializes jSplitPane3
*
* @return javax.swing.JSplitPane
*/
private JSplitPane getJSplitPane3() {
if (jSplitPane3 == null) {
jSplitPane3 = new JSplitPane();
jSplitPane3.setOrientation(javax.swing.JSplitPane.VERTICAL_SPLIT); // Generated
jSplitPane3.setTopComponent(getJPnlWef()); // Generated
jSplitPane3.setBottomComponent(getJPnlFill()); // Generated
}
return jSplitPane3;
}
/**
* This method initializes jPanel3
*
* @return javax.swing.JPanel
*/
private JPanel getJPnlWef() {
if (jPnlWef == null) {
jPnlWef = new DataPanel("wef-Daten");
jPnlWef.setBackground(java.awt.Color.white); // Generated
}
return jPnlWef;
}
/**
* This method initializes jPanel4
*
* @return javax.swing.JPanel
*/
private JPanel getJPnlFill() {
if (jPnlFill == null) {
jPnlFill = new DataPanel("Füll-Protokoll");
jPnlFill.setBackground(java.awt.Color.white); // Generated
}
return jPnlFill;
}
/**
* @see java.awt.event.ComponentListener#componentHidden(java.awt.event.ComponentEvent)
*/
public void componentHidden(ComponentEvent arg0) {
}
/**
* @see java.awt.event.ComponentListener#componentMoved(java.awt.event.ComponentEvent)
*/
public void componentMoved(ComponentEvent arg0) {
}
/**
* @see java.awt.event.ComponentListener#componentResized(java.awt.event.ComponentEvent)
*/
public void componentResized(ComponentEvent arg0) {
resizeSplitPanes(arg0.getComponent().getHeight(), arg0.getComponent().getWidth());
}
/**
* @see java.awt.event.ComponentListener#componentShown(java.awt.event.ComponentEvent)
*/
public void componentShown(ComponentEvent arg0) {
}
/* (non-Javadoc)
* @see java.util.Observer#update(java.util.Observable, java.lang.Object)
*/
public void update(Observable arg0, Object obj) {
if (obj instanceof String[]) {
String data[] = (String[]) obj;
jLblStatus.setText("JobId=" + data[0]+", vom " + data[1]
+ ", erstellt von " + data[2] + " , Formularname: " + data[3]);
}
}
public static void main(String[] args) {
try
{
UIManager.setLookAndFeel("net.java.plaf.windows.WindowsLookAndFeel");
}
catch ( Exception e ) {}
MainView mv = new MainView();
}
}