Biblioteca Java - Rev 32

Subversion Repositories:
Rev:
<?xml version="1.0" encoding="UTF-8"?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"><html xmlns="http://www.w3.org/1999/xhtml" lang="en"><head><meta http-equiv="Content-Type" content="text/html;charset=UTF-8"/><link rel="stylesheet" href="../.resources/report.css" type="text/css"/><link rel="shortcut icon" href="../.resources/report.gif" type="image/gif"/><title>ElevatorUI.java</title><link rel="stylesheet" href="../.resources/prettify.css" type="text/css"/><script type="text/javascript" src="../.resources/prettify.js"></script></head><body onload="window['PR_TAB_WIDTH']=4;prettyPrint()"><div class="breadcrumb" id="breadcrumb"><span class="info"><a href="../.sessions.html" class="el_session">Sessions</a></span><a href="../index.html" class="el_report">JaCoCoverage analysis of project &quot;ElevatorCurs&quot; (powered by JaCoCo from EclEmma)</a> &gt; <a href="index.source.html" class="el_package">elevatorcurs.ui</a> &gt; <span class="el_source">ElevatorUI.java</span></div><h1>ElevatorUI.java</h1><pre class="source lang-java linenums">/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package elevatorcurs.ui;

import elevatorcurs.model.Elevator;
import java.util.Observable;
import java.util.Observer;

/**
 *
 * @author Mihai Hulea mihai.hulea@aut.utcluj.ro
 */
public class ElevatorUI extends javax.swing.JFrame implements Observer{

    ElevatorMVCController ctrl;
    /**
     * Creates new form ElevatorUI
     */
<span class="nc" id="L22">    public ElevatorUI() {</span>
<span class="nc" id="L23">        initComponents();</span>
<span class="nc" id="L24">    }</span>
   
    public void initControler(ElevatorMVCController c){
<span class="nc" id="L27">        this.ctrl = c;</span>
<span class="nc" id="L28">    }</span>

    /**
     * This method is called from within the constructor to initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is always
     * regenerated by the Form Editor.
     */
    @SuppressWarnings(&quot;unchecked&quot;)
    // &lt;editor-fold defaultstate=&quot;collapsed&quot; desc=&quot;Generated Code&quot;&gt;//GEN-BEGIN:initComponents
    private void initComponents() {

<span class="nc" id="L39">        jButton1 = new javax.swing.JButton();</span>
<span class="nc" id="L40">        jButton2 = new javax.swing.JButton();</span>
<span class="nc" id="L41">        jButton3 = new javax.swing.JButton();</span>
<span class="nc" id="L42">        jButton4 = new javax.swing.JButton();</span>
<span class="nc" id="L43">        jScrollPane1 = new javax.swing.JScrollPane();</span>
<span class="nc" id="L44">        jTextArea1 = new javax.swing.JTextArea();</span>

<span class="nc" id="L46">        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);</span>

<span class="nc" id="L48">        jButton1.setText(&quot;Floor 3&quot;);</span>
<span class="nc" id="L49">        jButton1.addActionListener(new java.awt.event.ActionListener() {</span>
            public void actionPerformed(java.awt.event.ActionEvent evt) {
<span class="nc" id="L51">                jButton1ActionPerformed(evt);</span>
<span class="nc" id="L52">            }</span>
        });

<span class="nc" id="L55">        jButton2.setText(&quot;Floor 2&quot;);</span>
<span class="nc" id="L56">        jButton2.addActionListener(new java.awt.event.ActionListener() {</span>
            public void actionPerformed(java.awt.event.ActionEvent evt) {
<span class="nc" id="L58">                jButton2ActionPerformed(evt);</span>
<span class="nc" id="L59">            }</span>
        });

<span class="nc" id="L62">        jButton3.setText(&quot;Floor 1&quot;);</span>
<span class="nc" id="L63">        jButton3.addActionListener(new java.awt.event.ActionListener() {</span>
            public void actionPerformed(java.awt.event.ActionEvent evt) {
<span class="nc" id="L65">                jButton3ActionPerformed(evt);</span>
<span class="nc" id="L66">            }</span>
        });

<span class="nc" id="L69">        jButton4.setText(&quot;Floor 0&quot;);</span>
<span class="nc" id="L70">        jButton4.addActionListener(new java.awt.event.ActionListener() {</span>
            public void actionPerformed(java.awt.event.ActionEvent evt) {
<span class="nc" id="L72">                jButton4ActionPerformed(evt);</span>
<span class="nc" id="L73">            }</span>
        });

<span class="nc" id="L76">        jTextArea1.setColumns(20);</span>
<span class="nc" id="L77">        jTextArea1.setRows(5);</span>
<span class="nc" id="L78">        jScrollPane1.setViewportView(jTextArea1);</span>

<span class="nc" id="L80">        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());</span>
<span class="nc" id="L81">        getContentPane().setLayout(layout);</span>
<span class="nc" id="L82">        layout.setHorizontalGroup(</span>
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jButton4)
                    .addComponent(jButton1)
                    .addComponent(jButton2)
                    .addComponent(jButton3))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 309, Short.MAX_VALUE)
                .addContainerGap())
        );
<span class="nc" id="L95">        layout.setVerticalGroup(</span>
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jScrollPane1)
                    .addGroup(layout.createSequentialGroup()
                        .addComponent(jButton1)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addComponent(jButton2)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addComponent(jButton3)
                        .addGap(15, 15, 15)
                        .addComponent(jButton4)
                        .addGap(0, 0, Short.MAX_VALUE)))
                .addContainerGap())
        );

<span class="nc" id="L113">        pack();</span>
<span class="nc" id="L114">    }// &lt;/editor-fold&gt;//GEN-END:initComponents</span>

    private void jButton4ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton4ActionPerformed
<span class="nc" id="L117">        ctrl.executeFloorCommand(0);</span>
<span class="nc" id="L118">    }//GEN-LAST:event_jButton4ActionPerformed</span>

    private void jButton3ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton3ActionPerformed
<span class="nc" id="L121">        ctrl.executeFloorCommand(1);</span>
<span class="nc" id="L122">    }//GEN-LAST:event_jButton3ActionPerformed</span>

    private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton2ActionPerformed
<span class="nc" id="L125">        ctrl.executeFloorCommand(2);</span>
<span class="nc" id="L126">    }//GEN-LAST:event_jButton2ActionPerformed</span>

    private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed
<span class="nc" id="L129">        ctrl.executeFloorCommand(3);</span>
<span class="nc" id="L130">    }//GEN-LAST:event_jButton1ActionPerformed</span>

    /**
     * @param args the command line arguments
     */
    public static void main(String args[]) {
        /* Set the Nimbus look and feel */
        //&lt;editor-fold defaultstate=&quot;collapsed&quot; desc=&quot; Look and feel setting code (optional) &quot;&gt;
        /* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
         * For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html
         */
        try {
<span class="nc bnc" id="L142" title="All 2 branches missed.">            for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {</span>
<span class="nc bnc" id="L143" title="All 2 branches missed.">                if (&quot;Nimbus&quot;.equals(info.getName())) {</span>
<span class="nc" id="L144">                    javax.swing.UIManager.setLookAndFeel(info.getClassName());</span>
<span class="nc" id="L145">                    break;</span>
                }
            }
<span class="nc" id="L148">        } catch (ClassNotFoundException ex) {</span>
<span class="nc" id="L149">            java.util.logging.Logger.getLogger(ElevatorUI.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);</span>
<span class="nc" id="L150">        } catch (InstantiationException ex) {</span>
<span class="nc" id="L151">            java.util.logging.Logger.getLogger(ElevatorUI.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);</span>
<span class="nc" id="L152">        } catch (IllegalAccessException ex) {</span>
<span class="nc" id="L153">            java.util.logging.Logger.getLogger(ElevatorUI.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);</span>
<span class="nc" id="L154">        } catch (javax.swing.UnsupportedLookAndFeelException ex) {</span>
<span class="nc" id="L155">            java.util.logging.Logger.getLogger(ElevatorUI.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);</span>
<span class="nc" id="L156">        }</span>
        //&lt;/editor-fold&gt;

        /* Create and display the form */
<span class="nc" id="L160">        java.awt.EventQueue.invokeLater(new Runnable() {</span>
            public void run() {
<span class="nc" id="L162">                new ElevatorUI().setVisible(true);</span>
<span class="nc" id="L163">            }</span>
        });
<span class="nc" id="L165">    }</span>

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton jButton1;
    private javax.swing.JButton jButton2;
    private javax.swing.JButton jButton3;
    private javax.swing.JButton jButton4;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JTextArea jTextArea1;
    // End of variables declaration//GEN-END:variables

    @Override
    public void update(Observable o, Object arg) {
<span class="nc" id="L178">        this.jTextArea1.insert(((Elevator)arg).toString()+&quot;\n&quot;, 1);</span>
<span class="nc" id="L179">    }</span>
}
</pre><div class="footer"><span class="right">Created with <a href="http://www.eclemma.org/jacoco">JaCoCo</a> 0.7.4.201502262128</span></div></body></html>