/*
* Copyright (C) 2011 Alvaro Duran Tovar
*
* This file is part of AFA.
*
* AFA 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.
*
* This program 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.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
/*
* NewJFrame.java
*
* Created on Sep 17, 2009, 9:32:13 PM
*/
package afa.view;
import afa.control.*;
import afa.control.analisis.Analisis;
import afa.control.net.DownloadsHandler;
import afa.control.plugins.PluginsManager;
import afa.model.*;
import java.awt.*;
import java.io.File;
import java.util.*;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.swing.*;
import javax.swing.table.DefaultTableCellRenderer;
import javax.swing.tree.*;
/**
*
* @author Alvaro Duran Tovar
*/
public class Window extends javax.swing.JFrame {
private int panelSelected = 0;
private JPanel[] panels;
public String _text;
private boolean omitCheckStep = false;
private FirstStepPanel firstStepPanel = new FirstStepPanel();
private DeviceSelectionPanel deviceSelectionPanel = new DeviceSelectionPanel();
private PluginSelectionPanel pluginSelectionPanel = new PluginSelectionPanel();
private IgnoreOptionsPanel ignoreOptionsPanel = new IgnoreOptionsPanel();
private AnalisisFeedbackPanel analisisFeedbackPanel = new AnalisisFeedbackPanel();
/** Creates new form NewJFrame */
public Window() throws Exception {
initComponents();
panels = new JPanel[]{firstStepPanel, deviceSelectionPanel,
pluginSelectionPanel, ignoreOptionsPanel, analisisFeedbackPanel};
//center on screen
Dimension dim = Toolkit.getDefaultToolkit().getScreenSize();
setLocation((int) (dim.getWidth() / 2) - (this.getWidth() / 2), (int) (dim.getHeight() / 2) - (this.getHeight() / 2));
//para que las colunmnas esten centradas
DefaultTableCellRenderer cell = new DefaultTableCellRenderer();
cell.setHorizontalAlignment(DefaultTableCellRenderer.CENTER);
jTable1.setDefaultRenderer(Object.class, cell);
//
jTable1.setRowHeight(22);
//asignar renderizador de boton
new MyButtonCell(this.jTable1, this, 3);
stepsPanel.add(firstStepPanel, java.awt.BorderLayout.CENTER);
}
/** 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() {
jPopupMenu1 = new javax.swing.JPopupMenu();
jMenuItem5 = new javax.swing.JMenuItem();
jTabbedPane1 = new javax.swing.JTabbedPane();
jPanel1 = new javax.swing.JPanel();
nextButton = new javax.swing.JButton();
cancelButton = new javax.swing.JButton();
stepsPanel = new javax.swing.JPanel();
startButton = new javax.swing.JButton();
previousButton = new javax.swing.JButton();
updatePanel = new javax.swing.JPanel();
jScrollPane6 = new javax.swing.JScrollPane();
jTable1 = new javax.swing.JTable();
jButton12 = new javax.swing.JButton();
jLabel16 = new javax.swing.JLabel();
jButton7 = new javax.swing.JButton();
jComboBox1 = new javax.swing.JComboBox();
jProgressBar3 = new javax.swing.JProgressBar();
jProgressBar3.setVisible(false);
pluginsPanel = new javax.swing.JPanel();
jScrollPane4 = new javax.swing.JScrollPane();
jTree2 = new javax.swing.JTree();
jTextField1 = new javax.swing.JTextField();
jLabel7 = new javax.swing.JLabel();
jLabel8 = new javax.swing.JLabel();
jLabel9 = new javax.swing.JLabel();
jLabel10 = new javax.swing.JLabel();
jLabel12 = new javax.swing.JLabel();
jTextField5 = new javax.swing.JTextField();
jTextField6 = new javax.swing.JTextField();
jTextField3 = new javax.swing.JTextField();
jTextField4 = new javax.swing.JTextField();
jLabel17 = new javax.swing.JLabel();
jTextField7 = new javax.swing.JTextField();
jLabel1 = new javax.swing.JLabel();
jScrollPane1 = new javax.swing.JScrollPane();
jTextArea1 = new javax.swing.JTextArea();
jButton1 = new javax.swing.JButton();
jLabel2 = new javax.swing.JLabel();
jScrollPane2 = new javax.swing.JScrollPane();
jTextArea2 = new javax.swing.JTextArea();
jMenuBar1 = new javax.swing.JMenuBar();
jMenu1 = new javax.swing.JMenu();
jMenuItem4 = new javax.swing.JMenuItem();
jMenu2 = new javax.swing.JMenu();
jMenuItem1 = new javax.swing.JMenuItem();
jMenu3 = new javax.swing.JMenu();
jMenuItem2 = new javax.swing.JMenuItem();
jSeparator6 = new javax.swing.JSeparator();
jMenuItem3 = new javax.swing.JMenuItem();
jMenuItem5.setText("Borrar");
jMenuItem5.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jMenuItem5ActionPerformed(evt);
}
});
jPopupMenu1.add(jMenuItem5);
setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
setTitle("AFA v2.0");
setMinimumSize(new java.awt.Dimension(10, 63));
addWindowListener(new java.awt.event.WindowAdapter() {
public void windowClosing(java.awt.event.WindowEvent evt) {
formWindowClosing(evt);
}
});
jTabbedPane1.setMinimumSize(new java.awt.Dimension(10, 81));
jTabbedPane1.setPreferredSize(new java.awt.Dimension(703, 550));
jTabbedPane1.addMouseWheelListener(new java.awt.event.MouseWheelListener() {
public void mouseWheelMoved(java.awt.event.MouseWheelEvent evt) {
jTabbedPane1MouseWheelMoved(evt);
}
});
jTabbedPane1.addChangeListener(new javax.swing.event.ChangeListener() {
public void stateChanged(javax.swing.event.ChangeEvent evt) {
jTabbedPane1StateChanged(evt);
}
});
jPanel1.setPreferredSize(new java.awt.Dimension(633, 572));
nextButton.setText("Siguiente >");
nextButton.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
nextButtonActionPerformed(evt);
}
});
cancelButton.setText("Cancelar");
cancelButton.setEnabled(false);
cancelButton.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
cancelButtonActionPerformed(evt);
}
});
stepsPanel.setBorder(javax.swing.BorderFactory.createEtchedBorder());
stepsPanel.setLayout(new java.awt.BorderLayout());
startButton.setText("Iniciar");
startButton.setEnabled(false);
startButton.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
startButtonActionPerformed(evt);
}
});
previousButton.setText("< Anterior");
previousButton.setEnabled(false);
previousButton.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
previousButtonActionPerformed(evt);
}
});
javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
jPanel1.setLayout(jPanel1Layout);
jPanel1Layout.setHorizontalGroup(
jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel1Layout.createSequentialGroup()
.addContainerGap()
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
.addComponent(stepsPanel, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, 639, Short.MAX_VALUE)
.addGroup(jPanel1Layout.createSequentialGroup()
.addComponent(startButton)
.addGap(200, 200, 200)
.addComponent(previousButton)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(nextButton)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 27, Short.MAX_VALUE)
.addComponent(cancelButton)))
.addContainerGap())
);
jPanel1Layout.setVerticalGroup(
jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel1Layout.createSequentialGroup()
.addContainerGap()
.addComponent(stepsPanel, javax.swing.GroupLayout.DEFAULT_SIZE, 333, Short.MAX_VALUE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(startButton)
.addComponent(previousButton)
.addComponent(nextButton)
.addComponent(cancelButton))
.addGap(8, 8, 8))
);
jTabbedPane1.addTab("Analisis", jPanel1);
jTable1.setModel(new javax.swing.table.DefaultTableModel(
new Object [][] {
},
new String [] {
"Nombre", "Category", "Last updated", "Accion"
}
) {
Class[] types = new Class [] {
java.lang.String.class, java.lang.String.class, java.lang.String.class, java.lang.Object.class
};
boolean[] canEdit = new boolean [] {
false, false, false, false
};
public Class getColumnClass(int columnIndex) {
return types [columnIndex];
}
public boolean isCellEditable(int rowIndex, int columnIndex) {
return canEdit [columnIndex];
}
});
jTable1.setAutoResizeMode(javax.swing.JTable.AUTO_RESIZE_LAST_COLUMN);
jTable1.setSelectionMode(javax.swing.ListSelectionModel.SINGLE_SELECTION);
jScrollPane6.setViewportView(jTable1);
jButton12.setText("Buscar actualizaciones");
jButton12.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton12ActionPerformed(evt);
}
});
jLabel16.setLabelFor(jComboBox1);
jLabel16.setText("Accion:");
jButton7.setText("Ejecutar en todos");
jComboBox1.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Actualizar & Instalar", "Actualizar", "Instalar" }));
jProgressBar3.setIndeterminate(true);
javax.swing.GroupLayout updatePanelLayout = new javax.swing.GroupLayout(updatePanel);
updatePanel.setLayout(updatePanelLayout);
updatePanelLayout.setHorizontalGroup(
updatePanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, updatePanelLayout.createSequentialGroup()
.addContainerGap()
.addGroup(updatePanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
.addComponent(jScrollPane6, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, 639, Short.MAX_VALUE)
.addGroup(updatePanelLayout.createSequentialGroup()
.addComponent(jButton12)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(jProgressBar3, javax.swing.GroupLayout.DEFAULT_SIZE, 42, Short.MAX_VALUE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addComponent(jLabel16)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(jComboBox1, javax.swing.GroupLayout.PREFERRED_SIZE, 181, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(jButton7)))
.addContainerGap())
);
updatePanelLayout.setVerticalGroup(
updatePanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, updatePanelLayout.createSequentialGroup()
.addContainerGap()
.addComponent(jScrollPane6, javax.swing.GroupLayout.DEFAULT_SIZE, 319, Short.MAX_VALUE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(updatePanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
.addGroup(javax.swing.GroupLayout.Alignment.LEADING, updatePanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jLabel16)
.addComponent(jButton12, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
.addComponent(jComboBox1, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jProgressBar3, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(jButton7, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
.addContainerGap())
);
jTabbedPane1.addTab("Actualizacion", updatePanel);
javax.swing.tree.DefaultMutableTreeNode treeNode1 = new javax.swing.tree.DefaultMutableTreeNode("/");
jTree2.setModel(new javax.swing.tree.DefaultTreeModel(treeNode1));
jTree2.addMouseListener(new java.awt.event.MouseAdapter() {
public void mousePressed(java.awt.event.MouseEvent evt) {
jTree2MousePressed(evt);
}
public void mouseReleased(java.awt.event.MouseEvent evt) {
jTree2MouseReleased(evt);
}
});
jTree2.addTreeSelectionListener(new javax.swing.event.TreeSelectionListener() {
public void valueChanged(javax.swing.event.TreeSelectionEvent evt) {
jTree2ValueChanged(evt);
}
});
jScrollPane4.setViewportView(jTree2);
jTextField1.setToolTipText("Filter");
jTextField1.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jTextField1ActionPerformed(evt);
}
});
jLabel7.setLabelFor(jTextField3);
jLabel7.setText("Nombre");
jLabel8.setLabelFor(jTextField4);
jLabel8.setText("SO");
jLabel9.setLabelFor(jTextField6);
jLabel9.setText("Last Updated");
jLabel10.setText("Descripcion");
jLabel12.setLabelFor(jTextField5);
jLabel12.setText("Categoria");
jTextField5.setEditable(false);
jTextField6.setEditable(false);
jTextField3.setEditable(false);
jTextField4.setEditable(false);
jLabel17.setText("Autor");
jTextField7.setEditable(false);
jLabel1.setText("Tags");
jTextArea1.setColumns(20);
jTextArea1.setEditable(false);
jTextArea1.setLineWrap(true);
jTextArea1.setRows(5);
jScrollPane1.setViewportView(jTextArea1);
jButton1.setText("Add Filter");
jButton1.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton1ActionPerformed(evt);
}
});
jLabel2.setIcon(new javax.swing.ImageIcon(getClass().getResource("/afa/view/icons/clear.png"))); // NOI18N
jLabel2.setToolTipText("Clear filter");
jLabel2.addMouseListener(new java.awt.event.MouseAdapter() {
public void mouseClicked(java.awt.event.MouseEvent evt) {
jLabel2MouseClicked(evt);
}
});
jTextArea2.setColumns(20);
jTextArea2.setEditable(false);
jTextArea2.setLineWrap(true);
jTextArea2.setRows(5);
jScrollPane2.setViewportView(jTextArea2);
javax.swing.GroupLayout pluginsPanelLayout = new javax.swing.GroupLayout(pluginsPanel);
pluginsPanel.setLayout(pluginsPanelLayout);
pluginsPanelLayout.setHorizontalGroup(
pluginsPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, pluginsPanelLayout.createSequentialGroup()
.addContainerGap()
.addGroup(pluginsPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jScrollPane4, javax.swing.GroupLayout.DEFAULT_SIZE, 327, Short.MAX_VALUE)
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, pluginsPanelLayout.createSequentialGroup()
.addComponent(jButton1)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(jTextField1, javax.swing.GroupLayout.DEFAULT_SIZE, 197, Short.MAX_VALUE)
.addGap(0, 0, 0)
.addComponent(jLabel2)))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(pluginsPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 302, Short.MAX_VALUE)
.addGroup(pluginsPanelLayout.createSequentialGroup()
.addGroup(pluginsPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jLabel9)
.addComponent(jLabel17)
.addComponent(jLabel7)
.addComponent(jLabel8)
.addComponent(jLabel12))
.addGap(24, 24, 24)
.addGroup(pluginsPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jTextField5, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, 196, Short.MAX_VALUE)
.addComponent(jTextField6, javax.swing.GroupLayout.DEFAULT_SIZE, 196, Short.MAX_VALUE)
.addComponent(jTextField3, javax.swing.GroupLayout.DEFAULT_SIZE, 196, Short.MAX_VALUE)
.addComponent(jTextField4, javax.swing.GroupLayout.DEFAULT_SIZE, 196, Short.MAX_VALUE)
.addComponent(jTextField7, javax.swing.GroupLayout.DEFAULT_SIZE, 196, Short.MAX_VALUE)))
.addComponent(jLabel10)
.addComponent(jLabel1)
.addComponent(jScrollPane2, javax.swing.GroupLayout.DEFAULT_SIZE, 302, Short.MAX_VALUE))
.addContainerGap())
);
pluginsPanelLayout.setVerticalGroup(
pluginsPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, pluginsPanelLayout.createSequentialGroup()
.addContainerGap()
.addGroup(pluginsPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
.addGroup(pluginsPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jTextField3, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jLabel7))
.addGroup(pluginsPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jTextField1, javax.swing.GroupLayout.PREFERRED_SIZE, 25, Short.MAX_VALUE)
.addComponent(jButton1))
.addComponent(jLabel2, javax.swing.GroupLayout.PREFERRED_SIZE, 25, javax.swing.GroupLayout.PREFERRED_SIZE))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(pluginsPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(pluginsPanelLayout.createSequentialGroup()
.addGroup(pluginsPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jTextField4, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jLabel8))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(pluginsPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jTextField5, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jLabel12))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(pluginsPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jLabel9)
.addComponent(jTextField6, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(pluginsPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jTextField7, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jLabel17))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(jLabel10)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(jScrollPane2, javax.swing.GroupLayout.PREFERRED_SIZE, 225, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(jLabel1)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 23, Short.MAX_VALUE))
.addComponent(jScrollPane4, javax.swing.GroupLayout.DEFAULT_SIZE, 448, Short.MAX_VALUE))
.addContainerGap())
);
jTabbedPane1.addTab("Instalados", pluginsPanel);
getContentPane().add(jTabbedPane1, java.awt.BorderLayout.CENTER);
jMenu1.setText("File");
jMenuItem4.setText("Exit");
jMenuItem4.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jMenuItem4ActionPerformed(evt);
}
});
jMenu1.add(jMenuItem4);
jMenuBar1.add(jMenu1);
jMenu2.setText("Tool");
jMenuItem1.setText("Settings");
jMenuItem1.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jMenuItem1ActionPerformed(evt);
}
});
jMenu2.add(jMenuItem1);
jMenuBar1.add(jMenu2);
jMenu3.setText("Help");
jMenuItem2.setText("Help contents");
jMenu3.add(jMenuItem2);
jMenu3.add(jSeparator6);
jMenuItem3.setText("About");
jMenu3.add(jMenuItem3);
jMenuBar1.add(jMenu3);
setJMenuBar(jMenuBar1);
pack();
}// </editor-fold>//GEN-END:initComponents
private void jTabbedPane1StateChanged(javax.swing.event.ChangeEvent evt) {//GEN-FIRST:event_jTabbedPane1StateChanged
// TODO add your handling code here:
if (jTabbedPane1.getTitleAt(jTabbedPane1.getSelectedIndex()).equals("Instalados")) {
try {
Helper.cleanTree(jTree2);
Helper.loadPluginsOnTree(jTree2, null);
Helper.expandAll(jTree2, true);
} catch (Exception ex) {
ex.printStackTrace();
}
}
}//GEN-LAST:event_jTabbedPane1StateChanged
private void jTextField1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jTextField1ActionPerformed
try {
// TODO add your handling code here:
String text = this.jTextField1.getText();
Helper.cleanTree(jTree2);
((DefaultTreeModel) jTree2.getModel()).reload();
Helper.loadPluginsOnTree(jTree2, PluginsManager.getLocalPluginsByFilter(text));
Helper.expandAll(jTree2, true);
} catch (Exception ex) {
ex.printStackTrace();
}
}//GEN-LAST:event_jTextField1ActionPerformed
private void jTree2ValueChanged(javax.swing.event.TreeSelectionEvent evt) {//GEN-FIRST:event_jTree2ValueChanged
// TODO add your handling code here:
//check if a node is selected
if (evt.getNewLeadSelectionPath() == null
|| evt.getNewLeadSelectionPath().toString().split(", ").length != 3) {
clearForm();
} else {
try {
String s[] = Helper.treePathToStringArray(evt.getNewLeadSelectionPath());
Plugin p = Helper.getPluginByStrings(s[1], s[2]);
this.jTextField3.setText(p.getName());
this.jTextField4.setText(p.getOS());
this.jTextField5.setText(p.getCategory());
this.jTextField6.setText(p.getLastUpdated());
this.jTextField7.setText(p.getAuthor());
this.jTextArea2.setText(p.getDescription());
Vector<Tag> tags = p.getTags();
String text = "";
for(int i = 0;i<tags.size();i++){
text += tags.get(i).getName();
if(i < tags.size()-1) text += ", ";
}
this.jTextArea1.setText(text);
} catch (Exception ex) {
ex.printStackTrace();
}
}
}//GEN-LAST:event_jTree2ValueChanged
private void formWindowClosing(java.awt.event.WindowEvent evt) {//GEN-FIRST:event_formWindowClosing
// TODO add your handling code here:
if (DownloadsHandler.getCurrentDownloads() != 0) {
javax.swing.JOptionPane.showMessageDialog(null, "Hay descargas en curso",
"Error", JOptionPane.ERROR_MESSAGE);
} else {
System.exit(0);
}
}//GEN-LAST:event_formWindowClosing
public void loadRemotePluginList(Vector<Plugin> vec) {
javax.swing.table.DefaultTableModel model = (javax.swing.table.DefaultTableModel) jTable1.getModel();
for (Plugin p : vec) {
String action = (p.isRemoteNewer()) ? "Update" : "Install";
model.addRow(new Object[]{p.getName(), p.getCategory(), p.getLastUpdated(), action});
}
}
public void deleteAllRows() {
/*DefaultTableModel model = (DefaultTableModel) jTable1.getModel();
model.getDataVector().removeAllElements();
model.setRowCount(0);*/
jTable1.setModel(new javax.swing.table.DefaultTableModel(
new Object[][]{},
new String[]{
"Nombre", "Category", "Last updated", "Accion"
}));
new MyButtonCell(this.jTable1, this, 3);
}
private void jButton12ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton12ActionPerformed
//clean old rows
deleteAllRows();
//
jProgressBar3.setVisible(!jProgressBar3.isVisible());
try {
Vector<Plugin> vec = PluginsManager.getRemotePlugins(true);
loadRemotePluginList(vec);
} catch (Exception ex) {
ex.printStackTrace();
}
jProgressBar3.setVisible(!jProgressBar3.isVisible());
}//GEN-LAST:event_jButton12ActionPerformed
public void updateRemainingTechs(int techs) {
analisisFeedbackPanel.getTecnicasTerminadas().setText(Integer.toString(techs));
analisisFeedbackPanel.getProgresoTecnicas().setValue(techs);
if (techs == analisisFeedbackPanel.getProgresoTecnicas().getMaximum()) {
previousButton.setEnabled(true);
}
}
public void setTotalTechs(int techs) {
analisisFeedbackPanel.getTotalTecnicas().setText(Integer.toString(techs));
analisisFeedbackPanel.getProgresoTecnicas().setMaximum(techs);
}
private void jTabbedPane1MouseWheelMoved(java.awt.event.MouseWheelEvent evt) {//GEN-FIRST:event_jTabbedPane1MouseWheelMoved
// TODO add your handling code here:
int y = evt.getY();
if (y > 29) {
return;
}
if (evt.getWheelRotation() > 0) {
if (jTabbedPane1.getSelectedIndex() < jTabbedPane1.getTabCount() - 1) {
jTabbedPane1.setSelectedIndex(jTabbedPane1.getSelectedIndex() + 1);
}
} else {
if (jTabbedPane1.getSelectedIndex() > 0) {
jTabbedPane1.setSelectedIndex(jTabbedPane1.getSelectedIndex() - 1);
}
}
}//GEN-LAST:event_jTabbedPane1MouseWheelMoved
private void jMenuItem1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItem1ActionPerformed
// TODO add your handling code here:
//Settings.main(null);
}//GEN-LAST:event_jMenuItem1ActionPerformed
private void jMenuItem4ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItem4ActionPerformed
// TODO add your handling code here:
formWindowClosing(null);
}//GEN-LAST:event_jMenuItem4ActionPerformed
private void jTree2MouseReleased(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jTree2MouseReleased
// TODO add your handling code here:
TreePath selPath = jTree2.getPathForLocation(evt.getX(), evt.getY());
if (selPath == null) {
return;
} else {
jTree2.setSelectionPath(selPath);
}
if (evt.isPopupTrigger()) {
jPopupMenu1.show((Component) evt.getSource(), evt.getX(), evt.getY());
}
}//GEN-LAST:event_jTree2MouseReleased
private void jTree2MousePressed(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jTree2MousePressed
// TODO add your handling code here:
TreePath selPath = jTree2.getPathForLocation(evt.getX(), evt.getY());
if (selPath == null || selPath.getPathCount() != 3) {
return;
} else {
jTree2.setSelectionPath(selPath);
}
if (evt.isPopupTrigger()) {
jPopupMenu1.show((Component) evt.getSource(), evt.getX(), evt.getY());
}
}//GEN-LAST:event_jTree2MousePressed
private void jMenuItem5ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItem5ActionPerformed
// TODO add your handling code here:
String path = jTree2.getSelectionPath().toString();
path = path.replaceAll(", ", " ");
path = path.replaceAll("\\[", " ");
path = path.replaceAll("\\]", " ");
path = path.trim();
String[] s = path.split(" ");
try {
PluginsManager.delete(Constants.getDirectorioPlugins()
+ File.separator + s[1] + File.separator + s[2] + ".xml");
Helper.cleanTree(jTree2);
Helper.loadPluginsOnTree(jTree2, null);
Helper.expandAll(jTree2, true);
} catch (Exception ex) {
Logger.getLogger(Window.class.getName()).log(Level.SEVERE, null, ex);
}
}//GEN-LAST:event_jMenuItem5ActionPerformed
private void previousButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_previousButtonActionPerformed
// TODO add your handling code here:
cancelButton.setEnabled(false);
if (!nextButton.isEnabled() && panelSelected != panels.length - 1) {
nextButton.setEnabled(true);
}
if (panelSelected == panels.length - 1) {
startButton.setEnabled(true);
} else {
startButton.setEnabled(false);
}
if (panelSelected == 0) {
return;
}
stepsPanel.remove(panels[panelSelected]);
panelSelected--;
stepsPanel.add(panels[panelSelected], java.awt.BorderLayout.CENTER);
if (panelSelected == 0) {
previousButton.setEnabled(false);
}
this.repaint();
}//GEN-LAST:event_previousButtonActionPerformed
private void startButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_startButtonActionPerformed
try {
// TODO add your handling code here:
if (!checkStep(4)) {
return;
}
stepsPanel.remove(panels[panelSelected]);
panelSelected++;
stepsPanel.add(panels[panelSelected], java.awt.BorderLayout.CENTER);
startButton.setEnabled(false);
previousButton.setEnabled(false);
cancelButton.setEnabled(true);
this.repaint();
//analisis configure
Analisis.clean();
Analisis.setPlugins(pluginSelectionPanel.getSelectedPlugins());
Analisis.setPartitions(deviceSelectionPanel.getPartitionsVector());
Analisis.setIgnoreFileContentTechniques(ignoreOptionsPanel.isCheckBoxFileContentSelected());
Analisis.setIgnoreMD5HashTechniques(ignoreOptionsPanel.isCheckBoxHashMD5Selected());
Analisis.setIgnoreSHA1HashTechniques(ignoreOptionsPanel.isCheckBoxHashSHA1Selected());
Analisis.setIgnoreFindFileTechniques(ignoreOptionsPanel.isCheckBoxFindFileTechniqueSelected());
Analisis.setIgnoreRecursiveTechniques(ignoreOptionsPanel.isCheckBoxRecursiveSearchSelected());
try {
analisisFeedbackPanel.setAutoScrollDown(true);
analisisFeedbackPanel.getFeedBackPane().setText("");
Analisis.execute(this);
} catch (Exception ex) {
ex.printStackTrace();
}
} catch (Exception ex) {
ex.printStackTrace();
}
}//GEN-LAST:event_startButtonActionPerformed
private void cancelButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cancelButtonActionPerformed
// TODO add your handling code here:
Analisis.stop();
previousButton.setEnabled(true);
}//GEN-LAST:event_cancelButtonActionPerformed
private void nextButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_nextButtonActionPerformed
try {
// TODO add your handling code here:
if (!checkStep(panelSelected + 1)) {
return;
}
if (!previousButton.isEnabled()) {
previousButton.setEnabled(true);
}
if (panelSelected == panels.length - 1) {
return;
}
stepsPanel.remove(panels[panelSelected]);
panelSelected++;
stepsPanel.add(panels[panelSelected], java.awt.BorderLayout.CENTER);
if (panelSelected == panels.length - 2) {
nextButton.setEnabled(false);
startButton.setEnabled(true);
}
this.repaint();
} catch (Exception ex) {
ex.printStackTrace();
}
}//GEN-LAST:event_nextButtonActionPerformed
private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed
// TODO add your handling code here:
CreateFilter.createFilter(jTextField1);
}//GEN-LAST:event_jButton1ActionPerformed
private void jLabel2MouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jLabel2MouseClicked
// TODO add your handling code here:
jTextField1.setText("");
jTextField1.postActionEvent();
}//GEN-LAST:event_jLabel2MouseClicked
private void clearForm() {
this.jTextField3.setText("");
this.jTextField4.setText("");
this.jTextField5.setText("");
this.jTextField6.setText("");
this.jTextField7.setText("");
this.jTextArea2.setText("");
}
private void cleanLeafs(JTree tree) {
}
private boolean checkStep(int step) throws Exception {
if (omitCheckStep) {
return true;
}
switch (step) {
case 1:
return checkStep1();
case 2:
return checkStep2();
case 3:
return checkStep3();
case 4:
return checkStep4();
}
return false;
}
private boolean checkStep1() throws Exception {
if(firstStepPanel.checkPanel()){
deviceSelectionPanel.loadDevices();
return true;
}else
return false;
}
private boolean checkStep2() throws Exception {
boolean valid = deviceSelectionPanel.checkPanel();
if (valid) {
pluginSelectionPanel.init();
}
return valid;
}
private boolean checkStep3() throws Exception {
return pluginSelectionPanel.checkPanel();
}
private boolean checkStep4() {
return true;
}
public void printAnalisisMessage(String s, Color color){
analisisFeedbackPanel.printAnalisisMessage(s, color);
}
/**
* @param args the command line arguments
*/
public static void main(String args[]) throws Exception {
/*java.awt.EventQueue.invokeLater(new Runnable() {
public void run() {*/
new Window().setVisible(true);
/* }
});*/
}
private Point mousePoint = null;
// Variables declaration - do not modify//GEN-BEGIN:variables
private javax.swing.JButton cancelButton;
private javax.swing.JButton jButton1;
private javax.swing.JButton jButton12;
private javax.swing.JButton jButton7;
private javax.swing.JComboBox jComboBox1;
private javax.swing.JLabel jLabel1;
private javax.swing.JLabel jLabel10;
private javax.swing.JLabel jLabel12;
private javax.swing.JLabel jLabel16;
private javax.swing.JLabel jLabel17;
private javax.swing.JLabel jLabel2;
private javax.swing.JLabel jLabel7;
private javax.swing.JLabel jLabel8;
private javax.swing.JLabel jLabel9;
private javax.swing.JMenu jMenu1;
private javax.swing.JMenu jMenu2;
private javax.swing.JMenu jMenu3;
private javax.swing.JMenuBar jMenuBar1;
private javax.swing.JMenuItem jMenuItem1;
private javax.swing.JMenuItem jMenuItem2;
private javax.swing.JMenuItem jMenuItem3;
private javax.swing.JMenuItem jMenuItem4;
private javax.swing.JMenuItem jMenuItem5;
private javax.swing.JPanel jPanel1;
private javax.swing.JPopupMenu jPopupMenu1;
private javax.swing.JProgressBar jProgressBar3;
private javax.swing.JScrollPane jScrollPane1;
private javax.swing.JScrollPane jScrollPane2;
private javax.swing.JScrollPane jScrollPane4;
private javax.swing.JScrollPane jScrollPane6;
private javax.swing.JSeparator jSeparator6;
private javax.swing.JTabbedPane jTabbedPane1;
private javax.swing.JTable jTable1;
private javax.swing.JTextArea jTextArea1;
private javax.swing.JTextArea jTextArea2;
private javax.swing.JTextField jTextField1;
private javax.swing.JTextField jTextField3;
private javax.swing.JTextField jTextField4;
private javax.swing.JTextField jTextField5;
private javax.swing.JTextField jTextField6;
private javax.swing.JTextField jTextField7;
private javax.swing.JTree jTree2;
private javax.swing.JButton nextButton;
private javax.swing.JPanel pluginsPanel;
private javax.swing.JButton previousButton;
private javax.swing.JButton startButton;
private javax.swing.JPanel stepsPanel;
private javax.swing.JPanel updatePanel;
// End of variables declaration//GEN-END:variables
}