/*
* Copyright (c) 2010-2012 Thiago T. Sá
*
* This file is part of CloudReports.
*
* CloudReports is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* CloudReports is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* For more information about your rights as a user of CloudReports,
* refer to the LICENSE file or see <http://www.gnu.org/licenses/>.
*/
package cloudreports.gui.customers;
import cloudreports.dao.CustomerRegistryDAO;
import cloudreports.dao.NetworkMapEntryDAO;
import cloudreports.enums.BrokerPolicy;
import cloudreports.enums.UtilizationModel;
import cloudreports.gui.Dialog;
import cloudreports.gui.EditLink;
import cloudreports.gui.MainView;
import cloudreports.models.CustomerRegistry;
import cloudreports.models.NetworkMapEntry;
import cloudreports.models.UtilizationProfile;
import cloudreports.models.VirtualMachineRegistry;
import java.awt.Cursor;
import java.util.List;
import javax.swing.JScrollPane;
import javax.swing.ListSelectionModel;
import javax.swing.SwingConstants;
import javax.swing.table.DefaultTableCellRenderer;
import javax.swing.table.DefaultTableModel;
/**
* The SpecificCustomerView form.
* Most of its code is generated automatically by the NetBeans IDE.
*
* @author Thiago T. Sá
* @since 1.0
*/
public class SpecificCustomerView extends javax.swing.JPanel {
/** The customer registry whose information is being displayed. */
private CustomerRegistry cr;
/** An instance of customer registry DAO. */
private CustomerRegistryDAO crDAO;
/** The network table model. */
private DefaultTableModel networkTableModel;
/** The virtual machines table model. */
private DefaultTableModel vmsTableModel;
/** Creates a new SpecificUserGroupView form. */
public SpecificCustomerView(CustomerRegistry c) {
cr=c;
crDAO = new CustomerRegistryDAO();
initComponents();
fillFields(c);
}
/**
* Gets the customer registry being edited.
*
* @return the customer registry being edited.
*/
public CustomerRegistry getCustomerRegistry() {
return this.cr;
}
/**
* Sets the customer registry being edited.
*
* @param cr the customer registry being edited.
*/
public void setCustomerRegistry(CustomerRegistry cr) {
this.cr = cr;
}
/** 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("unchecked")
// <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
private void initComponents() {
jTabbedPane1 = new javax.swing.JTabbedPane();
jPanel3 = new javax.swing.JPanel();
jLabel1 = new javax.swing.JLabel();
removeVmButton = new javax.swing.JButton();
editVmButton = new javax.swing.JButton();
addVmButton = new javax.swing.JButton();
jScrollPane2 = new javax.swing.JScrollPane();
vmsTable = new javax.swing.JTable(vmsTableModel);
jPanel2 = new javax.swing.JPanel();
jLabel2 = new javax.swing.JLabel();
jPanel1 = new javax.swing.JPanel();
jLabel3 = new javax.swing.JLabel();
brokerPolicyBox = new javax.swing.JComboBox();
infoLabel = new javax.swing.JLabel();
jPanel5 = new javax.swing.JPanel();
jLabel6 = new javax.swing.JLabel();
jLabel7 = new javax.swing.JLabel();
jLabel8 = new javax.swing.JLabel();
jLabel9 = new javax.swing.JLabel();
jLabel10 = new javax.swing.JLabel();
jLabel11 = new javax.swing.JLabel();
lengthSpinner = new javax.swing.JSpinner();
fileSizeSpinner = new javax.swing.JSpinner();
outputSizeSpinner = new javax.swing.JSpinner();
cpuUMBox = new javax.swing.JComboBox();
ramUMBox = new javax.swing.JComboBox();
bwUMBox = new javax.swing.JComboBox();
jLabel12 = new javax.swing.JLabel();
peSpinner = new javax.swing.JSpinner();
jPanel4 = new javax.swing.JPanel();
networkLabel = new javax.swing.JLabel();
editLinkButton = new javax.swing.JButton();
jScrollPane1 = new javax.swing.JScrollPane();
networkTable = new javax.swing.JTable();
jTabbedPane1.setPreferredSize(new java.awt.Dimension(567, 486));
jLabel1.setText("Virtual machines owned by this customer:");
removeVmButton.setIcon(new javax.swing.ImageIcon(getClass().getResource("/cloudreports/gui/resources/remove.png"))); // NOI18N
removeVmButton.setText("Remove");
removeVmButton.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
removeVmButtonActionPerformed(evt);
}
});
editVmButton.setIcon(new javax.swing.ImageIcon(getClass().getResource("/cloudreports/gui/resources/edit.png"))); // NOI18N
editVmButton.setText("Edit");
editVmButton.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
editVmButtonActionPerformed(evt);
}
});
addVmButton.setIcon(new javax.swing.ImageIcon(getClass().getResource("/cloudreports/gui/resources/add.png"))); // NOI18N
addVmButton.setText("Add");
addVmButton.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
addVmButtonActionPerformed(evt);
}
});
JScrollPane tablePane = new JScrollPane( vmsTable );
tablePane.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS);
vmsTableModel = new javax.swing.table.DefaultTableModel(
new Object [][] {
},
new String [] {
"ID", "Amount", "Image Size", "Processing Elements", "MIPS", "RAM", "Bandwidth", "Priority", "Hypervisor", "Scheduling Policy"
}
) {
Class[] types = new Class [] {
java.lang.Integer.class, java.lang.Integer.class, java.lang.Long.class, java.lang.Integer.class, java.lang.Double.class, java.lang.Integer.class, java.lang.Long.class, java.lang.Integer.class, java.lang.String.class, java.lang.Integer.class
};
boolean[] canEdit = new boolean [] {
false, false, false, false, false, false, false, false, false, false
};
public Class getColumnClass(int columnIndex) {
return types [columnIndex];
}
public boolean isCellEditable(int rowIndex, int columnIndex) {
return canEdit [columnIndex];
}
};
vmsTable.setModel(vmsTableModel);
vmsTable.setAutoResizeMode(javax.swing.JTable.AUTO_RESIZE_OFF);
jScrollPane2.setViewportView(vmsTable);
DefaultTableCellRenderer renderer = new DefaultTableCellRenderer();
renderer.setHorizontalAlignment(SwingConstants.CENTER);
vmsTable.getColumnModel().getColumn(0).setCellRenderer(renderer);
vmsTable.getColumnModel().getColumn(1).setCellRenderer(renderer);
vmsTable.getColumnModel().getColumn(2).setCellRenderer(renderer);
vmsTable.getColumnModel().getColumn(3).setCellRenderer(renderer);
vmsTable.getColumnModel().getColumn(4).setCellRenderer(renderer);
vmsTable.getColumnModel().getColumn(5).setCellRenderer(renderer);
vmsTable.getColumnModel().getColumn(6).setCellRenderer(renderer);
vmsTable.getColumnModel().getColumn(7).setCellRenderer(renderer);
vmsTable.getColumnModel().getColumn(8).setCellRenderer(renderer);
vmsTable.getColumnModel().getColumn(9).setCellRenderer(renderer);
vmsTable.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
javax.swing.GroupLayout jPanel3Layout = new javax.swing.GroupLayout(jPanel3);
jPanel3.setLayout(jPanel3Layout);
jPanel3Layout.setHorizontalGroup(
jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel3Layout.createSequentialGroup()
.addContainerGap()
.addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jScrollPane2, javax.swing.GroupLayout.DEFAULT_SIZE, 597, Short.MAX_VALUE)
.addComponent(jLabel1)
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel3Layout.createSequentialGroup()
.addComponent(addVmButton)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addComponent(editVmButton)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addComponent(removeVmButton)))
.addContainerGap())
);
jPanel3Layout.linkSize(javax.swing.SwingConstants.HORIZONTAL, new java.awt.Component[] {addVmButton, editVmButton, removeVmButton});
jPanel3Layout.setVerticalGroup(
jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel3Layout.createSequentialGroup()
.addContainerGap()
.addComponent(jLabel1)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(removeVmButton)
.addComponent(editVmButton)
.addComponent(addVmButton))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(jScrollPane2, javax.swing.GroupLayout.DEFAULT_SIZE, 410, Short.MAX_VALUE)
.addContainerGap())
);
jTabbedPane1.addTab("Virtual Machines", jPanel3);
jLabel2.setText("This costumer's utilization profile:");
jPanel1.setBorder(javax.swing.BorderFactory.createTitledBorder("Datacenter Broker"));
jLabel3.setText("Broker policy:");
brokerPolicyBox.setModel(new javax.swing.DefaultComboBoxModel(BrokerPolicy.getBrokerPoliciesNames()));
brokerPolicyBox.addItemListener(new java.awt.event.ItemListener() {
public void itemStateChanged(java.awt.event.ItemEvent evt) {
brokerPolicyBoxItemStateChanged(evt);
}
});
infoLabel.setIcon(new javax.swing.ImageIcon(getClass().getResource("/cloudreports/gui/resources/info.png"))); // NOI18N
infoLabel.addMouseListener(new java.awt.event.MouseAdapter() {
public void mouseClicked(java.awt.event.MouseEvent evt) {
infoLabelMouseClicked(evt);
}
public void mouseEntered(java.awt.event.MouseEvent evt) {
infoLabelMouseEntered(evt);
}
public void mouseExited(java.awt.event.MouseEvent evt) {
infoLabelMouseExited(evt);
}
});
javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
jPanel1.setLayout(jPanel1Layout);
jPanel1Layout.setHorizontalGroup(
jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel1Layout.createSequentialGroup()
.addContainerGap()
.addComponent(jLabel3)
.addGap(37, 37, 37)
.addComponent(brokerPolicyBox, javax.swing.GroupLayout.PREFERRED_SIZE, 192, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(infoLabel)
.addContainerGap(209, Short.MAX_VALUE))
);
jPanel1Layout.setVerticalGroup(
jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel1Layout.createSequentialGroup()
.addContainerGap()
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.CENTER)
.addComponent(jLabel3)
.addComponent(brokerPolicyBox, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(infoLabel))
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
);
jPanel5.setBorder(javax.swing.BorderFactory.createTitledBorder("Cloudlets"));
jLabel6.setText("Maximum length:");
jLabel7.setText("File size:");
jLabel8.setText("Output size:");
jLabel9.setText("CPU utilization model:");
jLabel10.setText("RAM utilization model:");
jLabel11.setText("Bandwidth utilization model:");
lengthSpinner.setModel(new javax.swing.SpinnerNumberModel(Long.valueOf(10000L), Long.valueOf(1L), null, Long.valueOf(100L)));
lengthSpinner.addChangeListener(new javax.swing.event.ChangeListener() {
public void stateChanged(javax.swing.event.ChangeEvent evt) {
lengthSpinnerStateChanged(evt);
}
});
fileSizeSpinner.setModel(new javax.swing.SpinnerNumberModel(Long.valueOf(500L), Long.valueOf(1L), null, Long.valueOf(50L)));
fileSizeSpinner.addChangeListener(new javax.swing.event.ChangeListener() {
public void stateChanged(javax.swing.event.ChangeEvent evt) {
fileSizeSpinnerStateChanged(evt);
}
});
outputSizeSpinner.setModel(new javax.swing.SpinnerNumberModel(Long.valueOf(500L), Long.valueOf(1L), null, Long.valueOf(50L)));
outputSizeSpinner.addChangeListener(new javax.swing.event.ChangeListener() {
public void stateChanged(javax.swing.event.ChangeEvent evt) {
outputSizeSpinnerStateChanged(evt);
}
});
cpuUMBox.setModel(new javax.swing.DefaultComboBoxModel(UtilizationModel.getUtilizationModelNames()));
cpuUMBox.addItemListener(new java.awt.event.ItemListener() {
public void itemStateChanged(java.awt.event.ItemEvent evt) {
cpuUMBoxItemStateChanged(evt);
}
});
ramUMBox.setModel(new javax.swing.DefaultComboBoxModel(UtilizationModel.getUtilizationModelNames()));
ramUMBox.addItemListener(new java.awt.event.ItemListener() {
public void itemStateChanged(java.awt.event.ItemEvent evt) {
ramUMBoxItemStateChanged(evt);
}
});
bwUMBox.setModel(new javax.swing.DefaultComboBoxModel(UtilizationModel.getUtilizationModelNames()));
bwUMBox.addItemListener(new java.awt.event.ItemListener() {
public void itemStateChanged(java.awt.event.ItemEvent evt) {
bwUMBoxItemStateChanged(evt);
}
});
jLabel12.setText("Processing elements:");
peSpinner.setModel(new javax.swing.SpinnerNumberModel(Integer.valueOf(1), Integer.valueOf(1), null, Integer.valueOf(1)));
peSpinner.addChangeListener(new javax.swing.event.ChangeListener() {
public void stateChanged(javax.swing.event.ChangeEvent evt) {
peSpinnerStateChanged(evt);
}
});
javax.swing.GroupLayout jPanel5Layout = new javax.swing.GroupLayout(jPanel5);
jPanel5.setLayout(jPanel5Layout);
jPanel5Layout.setHorizontalGroup(
jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel5Layout.createSequentialGroup()
.addContainerGap()
.addGroup(jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel5Layout.createSequentialGroup()
.addGroup(jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jLabel12, javax.swing.GroupLayout.Alignment.TRAILING)
.addComponent(jLabel6, javax.swing.GroupLayout.Alignment.TRAILING)
.addComponent(jLabel7, javax.swing.GroupLayout.Alignment.TRAILING)
.addComponent(jLabel8, javax.swing.GroupLayout.Alignment.TRAILING))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(peSpinner, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(lengthSpinner, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(fileSizeSpinner, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(outputSizeSpinner, javax.swing.GroupLayout.PREFERRED_SIZE, 96, javax.swing.GroupLayout.PREFERRED_SIZE))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 140, Short.MAX_VALUE)
.addGroup(jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
.addComponent(jLabel11)
.addComponent(jLabel10)))
.addComponent(jLabel9, javax.swing.GroupLayout.Alignment.TRAILING))
.addGap(1, 1, 1)
.addGroup(jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(ramUMBox, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(bwUMBox, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(cpuUMBox, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
);
jPanel5Layout.linkSize(javax.swing.SwingConstants.HORIZONTAL, new java.awt.Component[] {fileSizeSpinner, lengthSpinner, outputSizeSpinner, peSpinner});
jPanel5Layout.linkSize(javax.swing.SwingConstants.HORIZONTAL, new java.awt.Component[] {bwUMBox, ramUMBox});
jPanel5Layout.setVerticalGroup(
jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel5Layout.createSequentialGroup()
.addContainerGap()
.addGroup(jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel5Layout.createSequentialGroup()
.addGroup(jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jLabel12)
.addComponent(peSpinner, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.CENTER)
.addComponent(jLabel6)
.addComponent(lengthSpinner, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.CENTER)
.addComponent(jLabel7)
.addComponent(fileSizeSpinner, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGap(7, 7, 7)
.addGroup(jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.CENTER)
.addComponent(jLabel8)
.addComponent(outputSizeSpinner, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
.addGroup(jPanel5Layout.createSequentialGroup()
.addGroup(jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jLabel9)
.addComponent(cpuUMBox, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addGroup(jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.CENTER)
.addComponent(jLabel10)
.addComponent(ramUMBox, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addGroup(jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.CENTER)
.addComponent(jLabel11)
.addComponent(bwUMBox, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))))
.addContainerGap(33, Short.MAX_VALUE))
);
javax.swing.GroupLayout jPanel2Layout = new javax.swing.GroupLayout(jPanel2);
jPanel2.setLayout(jPanel2Layout);
jPanel2Layout.setHorizontalGroup(
jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel2Layout.createSequentialGroup()
.addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel2Layout.createSequentialGroup()
.addContainerGap()
.addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
.addComponent(jPanel1, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(jLabel2, javax.swing.GroupLayout.Alignment.LEADING)))
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel2Layout.createSequentialGroup()
.addGap(9, 9, 9)
.addComponent(jPanel5, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)))
.addContainerGap())
);
jPanel2Layout.setVerticalGroup(
jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel2Layout.createSequentialGroup()
.addContainerGap()
.addComponent(jLabel2)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(18, 18, 18)
.addComponent(jPanel5, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addContainerGap(149, Short.MAX_VALUE))
);
jTabbedPane1.addTab("Utilization Profile", jPanel2);
networkLabel.setText("Description of links whose source is this costumer.");
editLinkButton.setIcon(new javax.swing.ImageIcon(getClass().getResource("/cloudreports/gui/resources/edit.png"))); // NOI18N
editLinkButton.setText("Edit link");
editLinkButton.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
editLinkButtonActionPerformed(evt);
}
});
networkTableModel = new javax.swing.table.DefaultTableModel(
new Object [][] {
},
new String [] {
"Destination", "Bandwidth", "Latency"
}
) {
Class[] types = new Class [] {
java.lang.String.class, java.lang.Double.class, java.lang.Double.class
};
boolean[] canEdit = new boolean [] {
false, false, false
};
public Class getColumnClass(int columnIndex) {
return types [columnIndex];
}
public boolean isCellEditable(int rowIndex, int columnIndex) {
return false;
}
};
networkTable.setModel(networkTableModel);
jScrollPane1.setViewportView(networkTable);
renderer.setHorizontalAlignment(SwingConstants.CENTER);
networkTable.getColumnModel().getColumn(0).setCellRenderer(renderer);
networkTable.getColumnModel().getColumn(1).setCellRenderer(renderer);
networkTable.getColumnModel().getColumn(2).setCellRenderer(renderer);
networkTable.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
javax.swing.GroupLayout jPanel4Layout = new javax.swing.GroupLayout(jPanel4);
jPanel4.setLayout(jPanel4Layout);
jPanel4Layout.setHorizontalGroup(
jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel4Layout.createSequentialGroup()
.addContainerGap()
.addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
.addComponent(jScrollPane1, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, 593, Short.MAX_VALUE)
.addGroup(jPanel4Layout.createSequentialGroup()
.addComponent(networkLabel)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 103, Short.MAX_VALUE)
.addComponent(editLinkButton, javax.swing.GroupLayout.PREFERRED_SIZE, 122, javax.swing.GroupLayout.PREFERRED_SIZE)))
.addContainerGap())
);
jPanel4Layout.setVerticalGroup(
jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel4Layout.createSequentialGroup()
.addContainerGap()
.addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(networkLabel, javax.swing.GroupLayout.PREFERRED_SIZE, 17, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(editLinkButton))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 429, Short.MAX_VALUE)
.addContainerGap())
);
jTabbedPane1.addTab("Network", jPanel4);
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
this.setLayout(layout);
layout.setHorizontalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jTabbedPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 633, Short.MAX_VALUE)
);
layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addComponent(jTabbedPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 546, Short.MAX_VALUE)
.addContainerGap())
);
}// </editor-fold>//GEN-END:initComponents
/**
* Launches a {@link EditLink} form when the Edit Link button is clicked
* if there is a selected link.
*
* @param evt an action event.
* @since 1.0
*/
private void editLinkButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_editLinkButtonActionPerformed
int i = networkTable.getSelectedRow();
if(i>=0) {
String dest = String.valueOf(networkTable.getModel().getValueAt(i, 0));
EditLink e = new EditLink(getCustomerRegistry().getName(), dest, this);
e.setLocationRelativeTo(this);
e.setVisible(true);
} else{
Dialog.showWarning(this, "Please select a link.");
}
}//GEN-LAST:event_editLinkButtonActionPerformed
/**
* Adds a virtual machine registry when the Add button is clicked.
*
* @param evt an action event.
* @since 1.0
*/
private void addVmButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_addVmButtonActionPerformed
getCustomerRegistry().getVmList().add(new VirtualMachineRegistry());
crDAO.updateCustomerRegistry(getCustomerRegistry());
updateVmsTable();
MainView.setUserGroupModified(true);
}//GEN-LAST:event_addVmButtonActionPerformed
/**
* Removes a virtual machine registry when the Remove button is clicked if
* there is a selected virtual machine.
*
* @param evt an action event.
* @since 1.0
*/
private void removeVmButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_removeVmButtonActionPerformed
int i = vmsTable.getSelectedRow();
if(i>=0) {
if(vmsTable.getRowCount()<2){
Dialog.showWarning(this, "There must be at least one virtual machine.");
return;
}
Long vmId = Long.valueOf(String.valueOf(vmsTable.getModel().getValueAt(i, 0)));
VirtualMachineRegistry vr = crDAO.getVirtualMachineRegistry(vmId, getCustomerRegistry().getId());
getCustomerRegistry().getVmList().remove(vr);
crDAO.updateCustomerRegistry(getCustomerRegistry());
updateVmsTable();
MainView.setUserGroupModified(true);
}
else {
Dialog.showWarning(this, "Please select a virtual machine.");
}
}//GEN-LAST:event_removeVmButtonActionPerformed
/**
* Launches a {@link EditVm} form when the Edit button is clicked if
* there is a selected virtual machine.
*
* @param evt an action event.
* @since 1.0
*/
private void editVmButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_editVmButtonActionPerformed
int i = vmsTable.getSelectedRow();
if(i>=0) {
Long vmId = Long.valueOf(String.valueOf(vmsTable.getModel().getValueAt(i, 0)));
VirtualMachineRegistry vmr = crDAO.getVirtualMachineRegistry(vmId, getCustomerRegistry().getId());
EditVm e = new EditVm(vmr, this);
e.setLocationRelativeTo(this);
e.setVisible(true);
}
else{
Dialog.showWarning(this, "Please select a virtual machine.");
}
}//GEN-LAST:event_editVmButtonActionPerformed
/**
* Changes the number of processing elements for each cloudlet
* whenever the state of the PE number spinner changes.
*
* @param evt a change event.
* @since 1.0
*/
private void peSpinnerStateChanged(javax.swing.event.ChangeEvent evt) {//GEN-FIRST:event_peSpinnerStateChanged
String s = String.valueOf(peSpinner.getValue());
getCustomerRegistry().getUtilizationProfile().setCloudletsPesNumber(Integer.valueOf(s));
crDAO.updateCustomerRegistry(getCustomerRegistry());
}//GEN-LAST:event_peSpinnerStateChanged
/**
* Changes the maximum length of each cloudlet
* whenever the state of the maximum length spinner changes.
*
* @param evt a change event.
* @since 1.0
*/
private void lengthSpinnerStateChanged(javax.swing.event.ChangeEvent evt) {//GEN-FIRST:event_lengthSpinnerStateChanged
String s = String.valueOf(lengthSpinner.getValue());
getCustomerRegistry().getUtilizationProfile().setLength(Long.valueOf(s));
crDAO.updateCustomerRegistry(getCustomerRegistry());
}//GEN-LAST:event_lengthSpinnerStateChanged
/**
* Changes the file size of each cloudlet whenever the state of the
* file size spinner changes.
*
* @param evt a change event.
* @since 1.0
*/
private void fileSizeSpinnerStateChanged(javax.swing.event.ChangeEvent evt) {//GEN-FIRST:event_fileSizeSpinnerStateChanged
String s = String.valueOf(fileSizeSpinner.getValue());
getCustomerRegistry().getUtilizationProfile().setFileSize(Long.valueOf(s));
crDAO.updateCustomerRegistry(getCustomerRegistry());
}//GEN-LAST:event_fileSizeSpinnerStateChanged
/**
* Changes the output size of each cloudlet whenever the state of the
* output size spinner changes.
*
* @param evt a change event.
* @since 1.0
*/
private void outputSizeSpinnerStateChanged(javax.swing.event.ChangeEvent evt) {//GEN-FIRST:event_outputSizeSpinnerStateChanged
String s = String.valueOf(outputSizeSpinner.getValue());
getCustomerRegistry().getUtilizationProfile().setOutputSize(Long.valueOf(s));
crDAO.updateCustomerRegistry(getCustomerRegistry());
}//GEN-LAST:event_outputSizeSpinnerStateChanged
/**
* Changes the CPU utilization model of this customer registry whenever the
* item of the CPU utilization model combo box changes.
*
* @param evt an item event.
* @since 1.0
*/
private void cpuUMBoxItemStateChanged(java.awt.event.ItemEvent evt) {//GEN-FIRST:event_cpuUMBoxItemStateChanged
getCustomerRegistry().getUtilizationProfile().setUtilizationModelCpuAlias(cpuUMBox.getSelectedItem().toString());
crDAO.updateCustomerRegistry(getCustomerRegistry());
}//GEN-LAST:event_cpuUMBoxItemStateChanged
/**
* Changes the RAM utilization model of this customer registry whenever the
* item of the RAM utilization model combo box changes.
*
* @param evt an item event.
* @since 1.0
*/
private void ramUMBoxItemStateChanged(java.awt.event.ItemEvent evt) {//GEN-FIRST:event_ramUMBoxItemStateChanged
getCustomerRegistry().getUtilizationProfile().setUtilizationModelRamAlias(ramUMBox.getSelectedItem().toString());
crDAO.updateCustomerRegistry(getCustomerRegistry());
}//GEN-LAST:event_ramUMBoxItemStateChanged
/**
* Changes the bandwidth utilization model of this customer registry whenever the
* item of the bandwidth utilization model combo box changes.
*
* @param evt an item event.
* @since 1.0
*/
private void bwUMBoxItemStateChanged(java.awt.event.ItemEvent evt) {//GEN-FIRST:event_bwUMBoxItemStateChanged
getCustomerRegistry().getUtilizationProfile().setUtilizationModelBwAlias(bwUMBox.getSelectedItem().toString());
crDAO.updateCustomerRegistry(getCustomerRegistry());
}//GEN-LAST:event_bwUMBoxItemStateChanged
/**
* Changes the broker policy of this customer registry whenever the
* item of the broker policy combo box changes.
*
* @param evt an item event.
* @since 1.0
*/
private void brokerPolicyBoxItemStateChanged(java.awt.event.ItemEvent evt) {//GEN-FIRST:event_brokerPolicyBoxItemStateChanged
getCustomerRegistry().getUtilizationProfile().setBrokerPolicyAlias(brokerPolicyBox.getSelectedItem().toString());
crDAO.updateCustomerRegistry(getCustomerRegistry());
}//GEN-LAST:event_brokerPolicyBoxItemStateChanged
/**
* Changes mouse cursor to {@link Cursor#HAND_CURSOR} whenever the it enters
* the area of the label.
*
* @param evt a mouse event.
* @since 1.0
*/
private void infoLabelMouseEntered(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_infoLabelMouseEntered
setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
}//GEN-LAST:event_infoLabelMouseEntered
/**
* Changes mouse cursor to {@link Cursor#DEFAULT_CURSOR} whenever the it
* leaves the area of the label.
*
* @param evt a mouse event.
* @since 1.0
*/
private void infoLabelMouseExited(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_infoLabelMouseExited
setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
}//GEN-LAST:event_infoLabelMouseExited
/**
* Shows an information dialog when the user clicks the label.
*
* @param evt a mouse event.
* @since 1.0
*/
private void infoLabelMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_infoLabelMouseClicked
setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
Dialog.showInfo(jPanel3, "The broker policy defines how this customer will\n"+
"choose datacenters to allocate its virtual machines\n"+
"and run its cloudlets.");
}//GEN-LAST:event_infoLabelMouseClicked
/**
* Changes the customer registry.
*
* @param c the new customer registry.
* @since 1.0
*/
public void changeRegistry(CustomerRegistry c) {
setCustomerRegistry(c);
fillFields(c);
}
/**
* Fill the fields of the form.
*
* @param customerRegistry the customer registry from which
* information will be taken to fill the form.
* @since 1.0
*/
private void fillFields(CustomerRegistry customerRegistry) {
/*
* Virtual Machines panel
*/
updateVmsTable();
/*
* Utilization profile panel
*/
UtilizationProfile up = customerRegistry.getUtilizationProfile();
brokerPolicyBox.setSelectedItem(up.getBrokerPolicyAlias());
cpuUMBox.setSelectedItem(up.getUtilizationModelCpuAlias());
ramUMBox.setSelectedItem(up.getUtilizationModelRamAlias());
bwUMBox.setSelectedItem(up.getUtilizationModelBwAlias());
peSpinner.setValue(up.getCloudletsPesNumber());
lengthSpinner.setValue(up.getLength());
fileSizeSpinner.setValue(up.getFileSize());
outputSizeSpinner.setValue(up.getOutputSize());
/*
* Network panel
*/
updateNetworkTable();
}
/**
* Gets the name of the customer registry.
*
* @return the name of the customer registry.
* @since 1.0
*/
public String getNameOfRegistry() {
return getCustomerRegistry().getName();
}
/**
* Updates the virtual machines table.
*
* @since 1.0
*/
public void updateVmsTable() {
while (vmsTable.getRowCount() > 0) {
vmsTableModel.removeRow(0);
}
for (VirtualMachineRegistry vmr : getCustomerRegistry().getVmList()) {
addVmToTable(vmr);
}
}
/**
* Adds a new virtual machine registry to the table.
*
* @param vmr the new virtual machine registry.
* @since 1.0
*/
private void addVmToTable(VirtualMachineRegistry vmr) {
vmsTableModel.insertRow(0, new Object[]{
vmr.getId(),
vmr.getAmount(),
vmr.getSize(),
vmr.getPesNumber(),
vmr.getMips(),
vmr.getRam(),
vmr.getBw(),
vmr.getPriority(),
vmr.getVmm(),
vmr.getSchedulingPolicyAlias()});
}
/**
* Updates the network table.
*
* @since 1.0
*/
public void updateNetworkTable() {
while (networkTable.getRowCount() > 0) {
networkTableModel.removeRow(0);
}
NetworkMapEntryDAO neDAO = new NetworkMapEntryDAO();
List<NetworkMapEntry> destinationList = neDAO.getListOfDestinations(getCustomerRegistry().getName());
for (NetworkMapEntry entry : destinationList) {
addLinkToTable(entry.getDestination(), entry.getBandwidth(), entry.getLatency());
}
}
/**
* Adds a new link to the network table.
*
* @param src the source of the link.
* @param bandwidth the bandwidth value.
* @param latency the latency value.
* @since 1.0
*/
private void addLinkToTable(String src, double bandwidth, double latency) {
networkTableModel.insertRow(0, new Object[]{
src,
bandwidth,
latency});
}
// Variables declaration - do not modify//GEN-BEGIN:variables
private javax.swing.JButton addVmButton;
private javax.swing.JComboBox brokerPolicyBox;
private javax.swing.JComboBox bwUMBox;
private javax.swing.JComboBox cpuUMBox;
private javax.swing.JButton editLinkButton;
private javax.swing.JButton editVmButton;
private javax.swing.JSpinner fileSizeSpinner;
private javax.swing.JLabel infoLabel;
private javax.swing.JLabel jLabel1;
private javax.swing.JLabel jLabel10;
private javax.swing.JLabel jLabel11;
private javax.swing.JLabel jLabel12;
private javax.swing.JLabel jLabel2;
private javax.swing.JLabel jLabel3;
private javax.swing.JLabel jLabel6;
private javax.swing.JLabel jLabel7;
private javax.swing.JLabel jLabel8;
private javax.swing.JLabel jLabel9;
private javax.swing.JPanel jPanel1;
private javax.swing.JPanel jPanel2;
private javax.swing.JPanel jPanel3;
private javax.swing.JPanel jPanel4;
private javax.swing.JPanel jPanel5;
private javax.swing.JScrollPane jScrollPane1;
private javax.swing.JScrollPane jScrollPane2;
private javax.swing.JTabbedPane jTabbedPane1;
private javax.swing.JSpinner lengthSpinner;
private javax.swing.JLabel networkLabel;
private javax.swing.JTable networkTable;
private javax.swing.JSpinner outputSizeSpinner;
private javax.swing.JSpinner peSpinner;
private javax.swing.JComboBox ramUMBox;
private javax.swing.JButton removeVmButton;
private javax.swing.JTable vmsTable;
// End of variables declaration//GEN-END:variables
}