tmp
[RRRRHHHH_Code] / ruralHouses / src / gui / StartWindow.java
index 3e538ca..600233b 100644 (file)
@@ -3,41 +3,33 @@ package gui;
 /**
  * @author willCodeForFood
  */
-import exceptions.DB4oManagerCreationException;
-import gui.BookRuralHouseGUI;
-
-import javax.swing.*;
-
-import configuration.ConfigXML;
-//import businessLogic.FacadeImplementation;
-import businessLogic.ApplicationFacadeInterface;
-import businessLogic.FacadeImplementation;
-
-import java.rmi.*;
 import java.awt.Color;
 import java.awt.Font;
-import java.awt.Rectangle;
-import java.awt.Dimension;
-import java.awt.BorderLayout;
-import java.awt.FlowLayout;
-import java.awt.GridLayout;
-import java.awt.GridBagLayout;
-import java.awt.GridBagConstraints;
 import java.awt.event.WindowAdapter;
 import java.awt.event.WindowEvent;
+import java.rmi.RMISecurityManager;
+
+import javax.swing.JButton;
+import javax.swing.JFrame;
+import javax.swing.JLabel;
+import javax.swing.JPanel;
+import javax.swing.SwingConstants;
+import javax.swing.UIManager;
+
+import configuration.ConfigXML;
 
 
+@SuppressWarnings("deprecation")
 public class StartWindow extends JFrame {
        
        private static final long serialVersionUID = 1L;
 
        private JPanel jContentPane = null;
-       private JButton boton1 = null;
        private JButton boton2 = null;
        private JButton boton3 = null;
        private static configuration.ConfigXML c;
 
-       public static ApplicationFacadeInterface facadeInterface;
+       //public static ApplicationFacadeInterface facadeInterface;
        private JLabel lblNewLabel;
        
        public static void main(String[] args) {
@@ -56,29 +48,8 @@ public class StartWindow extends JFrame {
                        UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
 
                        c=configuration.ConfigXML.getInstance();
-                       if (c.isBusinessLogicLocal())
-                               facadeInterface=new FacadeImplementation();
-                       else {
-                               
-                               final String businessLogicNode = c.getBusinessLogicNode();
-                               // Remote service name
-                               String serviceName = "/"+c.getServiceRMI();
-                               // RMI server port number
-                               int portNumber = Integer.parseInt(c.getPortRMI());
-                               // RMI server host IP IP 
-                               facadeInterface = (ApplicationFacadeInterface) Naming.lookup("rmi://"
-                                       + businessLogicNode + ":" + portNumber + serviceName);
-                       } 
-
-               } catch (java.rmi.ConnectException e) {
-                       a.lblNewLabel.setText("No business logic: Run BusinessLogicServer first!!");
-                       a.lblNewLabel.setForeground(Color.RED);
-                       System.out.println("Error in StartWindow: "+e.toString());
-               } catch (java.rmi.NotBoundException e) {
-                       a.lblNewLabel.setText("No business logic: Maybe problems running BusinessLogicServer");
-                       a.lblNewLabel.setForeground(Color.RED);
-                       System.out.println("Error in StartWindow: "+e.toString());
-               } catch (com.db4o.ext.DatabaseFileLockedException e) {
+               }catch (com.db4o.ext.DatabaseFileLockedException e) {
                        a.lblNewLabel.setText("Database locked: Do not run BusinessLogicServer or BusinessLogicServer!!");
                        a.lblNewLabel.setForeground(Color.RED);         
                        System.out.println("Error in StartWindow: "+e.toString());
@@ -87,7 +58,6 @@ public class StartWindow extends JFrame {
                        a.lblNewLabel.setForeground(Color.RED);         
                        System.out.println("Error in StartWindow: "+e.toString());
                }
-               //a.pack();
 
                
 
@@ -102,22 +72,14 @@ public class StartWindow extends JFrame {
                addWindowListener(new WindowAdapter() {
                        @Override
                        public void windowClosing(WindowEvent e) {
-                               ApplicationFacadeInterface facade=StartWindow.facadeInterface;
-                               try {
-                                       if (c.isBusinessLogicLocal()) facade.close();
-                               } catch (Exception e1) {
-                                       // TODO Auto-generated catch block
-                                       System.out.println("Error: "+e1.toString()+" , probably problems with Business Logic or Database");
-                               }
+
                                System.exit(1);
                        }
                });
                initialize();
                //this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        }
-       public static ApplicationFacadeInterface getBusinessLogic(){
-               return facadeInterface;
-       }
+       
        
 
        /**
@@ -139,39 +101,15 @@ public class StartWindow extends JFrame {
         */
        private JPanel getJContentPane() {
                if (jContentPane == null) {
-                       GridLayout gridLayout = new GridLayout();
-                       gridLayout.setRows(4);
-                       gridLayout.setColumns(1);
                        jContentPane = new JPanel();
-                       jContentPane.setLayout(gridLayout);
+                       jContentPane.setLayout(null);
                        jContentPane.add(getLblNewLabel());
-                       jContentPane.add(getBoton2(), null);
-                       jContentPane.add(getBoton3(), null);
-                       jContentPane.add(getBoton1(), null);
+                       jContentPane.add(getBoton2());
+                       jContentPane.add(getBoton3());
                }
                return jContentPane;
        }
 
-       /**
-        * This method initializes boton1
-        * 
-        * @return javax.swing.JButton
-        */
-       private JButton getBoton1() {
-               if (boton1 == null) {
-                       boton1 = new JButton();
-                       boton1.setText("Book rural house");
-                       boton1.addActionListener(new java.awt.event.ActionListener() {
-                               public void actionPerformed(java.awt.event.ActionEvent e) {
-                                       // C?digo cedido por la univerdad
-                                       JFrame a = new BookRuralHouseGUI();
-                                       a.setVisible(true);
-                               }
-                       });
-               }
-               return boton1;
-       }
-
        /**
         * This method initializes boton2
         * 
@@ -180,6 +118,7 @@ public class StartWindow extends JFrame {
        private JButton getBoton2() {
                if (boton2 == null) {
                        boton2 = new JButton();
+                       boton2.setBounds(0, 74, 479, 93);
                        boton2.setText("Login");
                        boton2.addActionListener(new java.awt.event.ActionListener() {
                                public void actionPerformed(java.awt.event.ActionEvent e) {
@@ -200,12 +139,13 @@ public class StartWindow extends JFrame {
        private JButton getBoton3() {
                if (boton3 == null) {
                        boton3 = new JButton();
+                       boton3.setBounds(0, 165, 479, 87);
                        boton3.setText("Query availability");
                        boton3.addActionListener(new java.awt.event.ActionListener() {
                                public void actionPerformed(java.awt.event.ActionEvent e) {
                                        // C?digo cedido por la universidad
                                        //JFrame a = new QueryAvailabilityWindow();
-                                       JFrame a = new QueryAvailabilityGUI();
+                                       JFrame a = new QueryAvailabilityGUI2();
 
                                        a.setVisible(true);
                                }
@@ -218,6 +158,7 @@ public class StartWindow extends JFrame {
        private JLabel getLblNewLabel() {
                if (lblNewLabel == null) {
                        lblNewLabel = new JLabel("Select option:");
+                       lblNewLabel.setBounds(0, 0, 479, 63);
                        lblNewLabel.setFont(new Font("Tahoma", Font.BOLD, 13));
                        lblNewLabel.setForeground(Color.BLACK);
                        lblNewLabel.setHorizontalAlignment(SwingConstants.CENTER);