package webuicheck;
import java.awt.BorderLayout;
import java.awt.Component;
import java.awt.event.ActionEvent;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.awt.image.BufferedImage;
import java.io.File;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.imageio.ImageIO;
import javax.swing.AbstractAction;
import javax.swing.BorderFactory;
import javax.swing.GroupLayout;
import javax.swing.ImageIcon;
import javax.swing.JButton;
import javax.swing.JDialog;
import javax.swing.JFileChooser;
import javax.swing.JLabel;
import javax.swing.JMenu;
import javax.swing.JMenuBar;
import javax.swing.JMenuItem;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JTextArea;
import javax.swing.JTextField;
import javax.swing.LayoutStyle;
import javax.swing.SwingConstants;
import javax.swing.border.BevelBorder;
import javax.swing.border.LineBorder;
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
/*
* UserInterface.java
*
* Created on 30.03.2010, 13:27:52
*/
/**
* This code was edited or generated using CloudGarden's Jigloo
* SWT/Swing GUI Builder, which is free for non-commercial
* use. If Jigloo is being used commercially (ie, by a corporation,
* company or business for any purpose whatever) then you
* should purchase a license for each developer using Jigloo.
* Please visit www.cloudgarden.com for details.
* Use of Jigloo implies acceptance of these licensing terms.
* A COMMERCIAL LICENSE HAS NOT BEEN PURCHASED FOR
* THIS MACHINE, SO JIGLOO OR THIS CODE CANNOT BE USED
* LEGALLY FOR ANY CORPORATE OR COMMERCIAL PURPOSE.
*/
/**
*
* @author user
*/
public class UserInterface extends javax.swing.JFrame {
{
// Set Look & Feel
try {
javax.swing.UIManager
.setLookAndFeel("com.sun.java.swing.plaf.nimbus.NimbusLookAndFeel");
// com.seaglasslookandfeel.SeaGlassLookAndFeel
// javax.swing.UIManager.setLookAndFeel("com.seaglasslookandfeel.SeaGlassLookAndFeel");
} catch (Exception e) {
e.printStackTrace();
}
}
private int TAKESCREENSHOTS = 0;
private StartRun rt;
private String directoryPath;
private String selectedPlatform;
private JMenuItem jMenuItem1;
private JButton jButton1;
private JLabel jLabel14;
private JTextField newSubproject;
private JPanel jPanel3;
private JDialog AddConfig;
private JPanel jPanel2;
private JTextArea jTextArea2;
private JPanel jPanel1;
private JLabel jLabel13;
private JLabel jLabel12;
private JDialog About;
private AbstractAction Help;
private JScrollPane jScrollPane3;
private JTextArea tfExcludeURLsTxt;
private JLabel jLabel11;
private JLabel jLabel10;
private JTextField tfBaseURLTxt;
private JLabel jLabel9;
private JMenuItem aboutme;
private JMenu jMenu2;
private JMenu jMenu1;
private JMenuBar jMenuBar1;
/** Creates new form UserInterface */
public UserInterface() {
initComponents();
setLocationRelativeTo(null);
GroupLayout layout = new GroupLayout(getContentPane());
getContentPane().setLayout(layout);
layout.setVerticalGroup(layout
.createSequentialGroup()
.addContainerGap()
.addGroup(
layout.createParallelGroup(
GroupLayout.Alignment.BASELINE)
.addComponent(ddlBrowser,
GroupLayout.Alignment.BASELINE,
GroupLayout.PREFERRED_SIZE, 25,
GroupLayout.PREFERRED_SIZE)
.addComponent(jLabel7,
GroupLayout.Alignment.BASELINE,
GroupLayout.PREFERRED_SIZE,
GroupLayout.PREFERRED_SIZE,
GroupLayout.PREFERRED_SIZE)
.addComponent(jLabel1,
GroupLayout.Alignment.BASELINE,
GroupLayout.PREFERRED_SIZE, 18,
GroupLayout.PREFERRED_SIZE))
.addPreferredGap(LayoutStyle.ComponentPlacement.RELATED)
.addGroup(
layout.createParallelGroup()
.addGroup(
GroupLayout.Alignment.LEADING,
layout.createSequentialGroup()
.addGroup(
layout.createParallelGroup(
GroupLayout.Alignment.BASELINE)
.addComponent(
ddlPlatform,
GroupLayout.Alignment.BASELINE,
GroupLayout.PREFERRED_SIZE,
25,
GroupLayout.PREFERRED_SIZE)
.addComponent(
jLabel8,
GroupLayout.Alignment.BASELINE,
GroupLayout.PREFERRED_SIZE,
18,
GroupLayout.PREFERRED_SIZE))
.addPreferredGap(
LayoutStyle.ComponentPlacement.RELATED)
.addGroup(
layout.createParallelGroup(
GroupLayout.Alignment.BASELINE)
.addComponent(
tfStartLink,
GroupLayout.Alignment.BASELINE,
GroupLayout.PREFERRED_SIZE,
25,
GroupLayout.PREFERRED_SIZE)
.addComponent(
jLabel9,
GroupLayout.Alignment.BASELINE,
GroupLayout.PREFERRED_SIZE,
18,
GroupLayout.PREFERRED_SIZE))
.addComponent(
jLabel3,
GroupLayout.PREFERRED_SIZE,
GroupLayout.PREFERRED_SIZE,
GroupLayout.PREFERRED_SIZE)
.addPreferredGap(
LayoutStyle.ComponentPlacement.RELATED)
.addGroup(
layout.createParallelGroup()
.addGroup(
GroupLayout.Alignment.LEADING,
layout.createSequentialGroup()
.addComponent(
jLabel4,
GroupLayout.PREFERRED_SIZE,
GroupLayout.PREFERRED_SIZE,
GroupLayout.PREFERRED_SIZE)
.addGap(25))
.addGroup(
GroupLayout.Alignment.LEADING,
layout.createSequentialGroup()
.addComponent(
jLabel10,
GroupLayout.PREFERRED_SIZE,
18,
GroupLayout.PREFERRED_SIZE)
.addPreferredGap(
LayoutStyle.ComponentPlacement.RELATED))
.addComponent(
tfBaseURLTxt,
GroupLayout.Alignment.LEADING,
GroupLayout.PREFERRED_SIZE,
25,
GroupLayout.PREFERRED_SIZE))
.addPreferredGap(
LayoutStyle.ComponentPlacement.UNRELATED)
.addGroup(
layout.createParallelGroup()
.addGroup(
GroupLayout.Alignment.LEADING,
layout.createSequentialGroup()
.addComponent(
jLabel11,
GroupLayout.PREFERRED_SIZE,
18,
GroupLayout.PREFERRED_SIZE)
.addGap(0,
107,
Short.MAX_VALUE))
.addComponent(
jScrollPane3,
GroupLayout.Alignment.LEADING,
0,
125,
Short.MAX_VALUE))
.addGap(16)
.addGroup(
layout.createParallelGroup(
GroupLayout.Alignment.BASELINE)
.addComponent(
tfPort,
GroupLayout.Alignment.BASELINE,
GroupLayout.PREFERRED_SIZE,
GroupLayout.PREFERRED_SIZE,
GroupLayout.PREFERRED_SIZE)
.addComponent(
jLabel5,
GroupLayout.Alignment.BASELINE,
GroupLayout.PREFERRED_SIZE,
GroupLayout.PREFERRED_SIZE,
GroupLayout.PREFERRED_SIZE))
.addGap(24)
.addComponent(
cbTakeScreenshots,
GroupLayout.PREFERRED_SIZE,
22,
GroupLayout.PREFERRED_SIZE)
.addPreferredGap(
LayoutStyle.ComponentPlacement.UNRELATED)
.addGroup(
layout.createParallelGroup(
GroupLayout.Alignment.BASELINE)
.addComponent(
bBrowse,
GroupLayout.Alignment.BASELINE,
GroupLayout.PREFERRED_SIZE,
25,
GroupLayout.PREFERRED_SIZE)
.addComponent(
jLabel6,
GroupLayout.Alignment.BASELINE,
GroupLayout.PREFERRED_SIZE,
18,
GroupLayout.PREFERRED_SIZE))
.addPreferredGap(
LayoutStyle.ComponentPlacement.UNRELATED)
.addComponent(
jScrollPane1,
GroupLayout.PREFERRED_SIZE,
90,
GroupLayout.PREFERRED_SIZE))
.addComponent(jScrollPane2,
GroupLayout.Alignment.LEADING, 0, 438,
Short.MAX_VALUE))
.addPreferredGap(LayoutStyle.ComponentPlacement.RELATED)
.addComponent(jLabel2, GroupLayout.PREFERRED_SIZE, 18,
GroupLayout.PREFERRED_SIZE)
.addPreferredGap(LayoutStyle.ComponentPlacement.UNRELATED)
.addGroup(
layout.createParallelGroup(
GroupLayout.Alignment.BASELINE)
.addComponent(bStop,
GroupLayout.Alignment.BASELINE,
GroupLayout.PREFERRED_SIZE, 25,
GroupLayout.PREFERRED_SIZE)
.addComponent(bGo,
GroupLayout.Alignment.BASELINE,
GroupLayout.PREFERRED_SIZE, 25,
GroupLayout.PREFERRED_SIZE))
.addContainerGap(39, 39));
layout.setHorizontalGroup(layout
.createSequentialGroup()
.addContainerGap()
.addGroup(
layout.createParallelGroup()
.addComponent(jLabel4,
GroupLayout.Alignment.LEADING,
GroupLayout.PREFERRED_SIZE,
GroupLayout.PREFERRED_SIZE,
GroupLayout.PREFERRED_SIZE)
.addComponent(jLabel3,
GroupLayout.Alignment.LEADING,
GroupLayout.PREFERRED_SIZE,
GroupLayout.PREFERRED_SIZE,
GroupLayout.PREFERRED_SIZE))
.addGap(7)
.addGroup(
layout.createParallelGroup()
.addGroup(
GroupLayout.Alignment.LEADING,
layout.createSequentialGroup()
.addComponent(
jLabel6,
GroupLayout.PREFERRED_SIZE,
145,
GroupLayout.PREFERRED_SIZE)
.addGap(195)
.addGroup(
layout.createParallelGroup()
.addGroup(
layout.createSequentialGroup()
.addComponent(
bBrowse,
GroupLayout.PREFERRED_SIZE,
90,
GroupLayout.PREFERRED_SIZE))
.addGroup(
GroupLayout.Alignment.LEADING,
layout.createSequentialGroup()
.addGap(18)
.addComponent(
bStop,
GroupLayout.PREFERRED_SIZE,
72,
GroupLayout.PREFERRED_SIZE)))
.addGap(0, 0, Short.MAX_VALUE))
.addGroup(
layout.createSequentialGroup()
.addGroup(
layout.createParallelGroup()
.addComponent(
jLabel5,
GroupLayout.Alignment.LEADING,
0,
107,
Short.MAX_VALUE)
.addGroup(
GroupLayout.Alignment.LEADING,
layout.createSequentialGroup()
.addComponent(
bGo,
GroupLayout.PREFERRED_SIZE,
73,
GroupLayout.PREFERRED_SIZE)
.addGap(0,
34,
Short.MAX_VALUE))
.addComponent(
jLabel11,
GroupLayout.Alignment.LEADING,
0,
107,
Short.MAX_VALUE)
.addComponent(
jLabel10,
GroupLayout.Alignment.LEADING,
0,
107,
Short.MAX_VALUE)
.addComponent(
jLabel9,
GroupLayout.Alignment.LEADING,
0,
107,
Short.MAX_VALUE)
.addComponent(
jLabel8,
GroupLayout.Alignment.LEADING,
0,
107,
Short.MAX_VALUE)
.addComponent(
jLabel1,
GroupLayout.Alignment.LEADING,
0,
104,
Short.MAX_VALUE))
.addPreferredGap(
LayoutStyle.ComponentPlacement.RELATED)
.addGroup(
layout.createParallelGroup()
.addComponent(
tfPort,
GroupLayout.Alignment.LEADING,
GroupLayout.PREFERRED_SIZE,
319,
GroupLayout.PREFERRED_SIZE)
.addComponent(
jScrollPane3,
GroupLayout.Alignment.LEADING,
GroupLayout.PREFERRED_SIZE,
319,
GroupLayout.PREFERRED_SIZE)
.addComponent(
tfBaseURLTxt,
GroupLayout.Alignment.LEADING,
GroupLayout.PREFERRED_SIZE,
319,
GroupLayout.PREFERRED_SIZE)
.addComponent(
tfStartLink,
GroupLayout.Alignment.LEADING,
GroupLayout.PREFERRED_SIZE,
319,
GroupLayout.PREFERRED_SIZE)
.addComponent(
ddlPlatform,
GroupLayout.Alignment.LEADING,
GroupLayout.PREFERRED_SIZE,
319,
GroupLayout.PREFERRED_SIZE)
.addComponent(
ddlBrowser,
GroupLayout.Alignment.LEADING,
GroupLayout.PREFERRED_SIZE,
319,
GroupLayout.PREFERRED_SIZE)))
.addComponent(cbTakeScreenshots,
GroupLayout.Alignment.LEADING, 0, 430,
Short.MAX_VALUE)
.addGroup(
layout.createSequentialGroup()
.addComponent(
jScrollPane1,
GroupLayout.PREFERRED_SIZE,
430,
GroupLayout.PREFERRED_SIZE)
.addGap(0, 0, Short.MAX_VALUE))
.addGroup(
layout.createSequentialGroup()
.addComponent(
jLabel2,
GroupLayout.PREFERRED_SIZE,
430,
GroupLayout.PREFERRED_SIZE)
.addGap(0, 0, Short.MAX_VALUE)))
.addGap(40)
.addGroup(
layout.createParallelGroup()
.addComponent(jScrollPane2,
GroupLayout.Alignment.LEADING,
GroupLayout.PREFERRED_SIZE, 232,
GroupLayout.PREFERRED_SIZE)
.addComponent(jLabel7,
GroupLayout.Alignment.LEADING,
GroupLayout.PREFERRED_SIZE, 232,
GroupLayout.PREFERRED_SIZE))
.addContainerGap(36, 36));
layout.linkSize(SwingConstants.HORIZONTAL, new Component[] {
jScrollPane3, tfBaseURLTxt, tfStartLink, ddlPlatform,
ddlBrowser });
this.setTitle("Web UI Checker");
setPlatformText();
tfPort.setText("4444");
}
/**
* 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() {
bGo = new javax.swing.JButton();
bStop = new javax.swing.JButton();
ddlBrowser = new javax.swing.JComboBox();
jLabel1 = new javax.swing.JLabel();
jLabel2 = new javax.swing.JLabel();
jLabel3 = new javax.swing.JLabel();
jLabel4 = new javax.swing.JLabel();
tfUsername = new javax.swing.JTextField();
tfPassword = new javax.swing.JTextField();
jLabel5 = new javax.swing.JLabel();
tfPort = new javax.swing.JTextField(15);
jLabel6 = new javax.swing.JLabel();
{
bBrowse = new javax.swing.JButton();
bBrowse.setText("Browse");
bBrowse.setSize(72, 23);
bBrowse.addActionListener(new java.awt.event.ActionListener() {
@Override
public void actionPerformed(java.awt.event.ActionEvent evt) {
bBrowseActionPerformed(evt);
}
});
}
jScrollPane1 = new javax.swing.JScrollPane();
taPath = new javax.swing.JTextArea();
jScrollPane2 = new javax.swing.JScrollPane();
{
jTextArea1 = new javax.swing.JTextArea();
jScrollPane2.setViewportView(jTextArea1);
jTextArea1.setColumns(20);
jTextArea1.setEditable(false);
jTextArea1.setFont(new java.awt.Font("Arial", 0, 12)); // NOI18N
jTextArea1.setRows(5);
jTextArea1
.setText("\n* Deactivate OS screensaver\n* Currently Safari can be used \nonly on Mac OS\n* Currently Opera does not \nwork due to Selenium related\nissues\n*Always keep the browser on top"
+ "\n* The Exclude list can contain whole"
+ "\n domains, or just words contained"
+ "\n in links eg cancel, logout"
+ "\n* If protocol changes from http to https"
+ "\n during crawling, use just the domain or"
+ "\n part of the domain, eg. ://1and1"
+ "\n for Base URL");
}
jLabel7 = new javax.swing.JLabel();
jLabel8 = new javax.swing.JLabel();
ddlPlatform = new javax.swing.JComboBox();
tfStartLink = new javax.swing.JTextField(20);
tfStartLink.addMouseListener(new MouseAdapter() {
@Override
public void mousePressed(MouseEvent e) {
tfStartLink.selectAll();
}
});
cbTakeScreenshots = new javax.swing.JCheckBox();
setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
setResizable(true);
bGo.setText("Go!");
bGo.addActionListener(new java.awt.event.ActionListener() {
@Override
public void actionPerformed(java.awt.event.ActionEvent evt) {
bGoActionPerformed(evt);
}
});
bStop.setText("Stop!");
bStop.setSize(72, 23);
bStop.addActionListener(new java.awt.event.ActionListener() {
@Override
public void actionPerformed(java.awt.event.ActionEvent evt) {
bStopActionPerformed(evt);
}
});
// get browser List from profile.xml
String[] bList = new ProfilesXML().getBrowsers();
// new String[] { "*firefox3 C:\\PROGRA~2\\MOZILL~1\\firefox.exe",
// *firefox3", "*iexplore", "*iexploreproxy", "*opera", "*safari" }
ddlBrowser.setModel(new javax.swing.DefaultComboBoxModel(bList));
jLabel1.setText("Select browser:");
jLabel1.setSize(120, 16);
jLabel1.setHorizontalAlignment(SwingConstants.RIGHT);
jLabel2.setText("*Always keep the browser in the foreground (on top)");
tfUsername.addActionListener(new java.awt.event.ActionListener() {
@Override
public void actionPerformed(java.awt.event.ActionEvent evt) {
tfUsernameActionPerformed(evt);
}
});
tfPassword.addActionListener(new java.awt.event.ActionListener() {
@Override
public void actionPerformed(java.awt.event.ActionEvent evt) {
tfPasswordActionPerformed(evt);
}
});
jLabel5.setText("Selenium port:");
jLabel5.setHorizontalAlignment(SwingConstants.RIGHT);
jLabel6.setText("Change results path:");
taPath.setColumns(20);
taPath.setEditable(false);
taPath.setLineWrap(true);
taPath.setRows(5);
jScrollPane1.setViewportView(taPath);
taPath.setPreferredSize(new java.awt.Dimension(372, 94));
jLabel7.setForeground(new java.awt.Color(255, 51, 51));
jLabel7.setText("Read before use:");
{
jLabel9 = new JLabel();
jLabel9.setText("Start Link:");
jLabel9.setSize(79, 16);
jLabel9.setHorizontalAlignment(SwingConstants.RIGHT);
}
{
tfBaseURLTxt = new JTextField();
tfBaseURLTxt.setColumns(20);
tfBaseURLTxt.setText("http://youraddress");
tfBaseURLTxt.addMouseListener(new MouseAdapter() {
@Override
public void mousePressed(MouseEvent e) {
tfBaseURLTxt.selectAll();
}
});
}
{
jLabel10 = new JLabel();
jLabel10.setText("Base URL:");
jLabel10.setSize(79, 16);
jLabel10.setHorizontalAlignment(SwingConstants.RIGHT);
}
{
jLabel11 = new JLabel();
jLabel11.setText("Excludes:");
jLabel11.setSize(79, 16);
jLabel11.setHorizontalAlignment(SwingConstants.RIGHT);
}
{
jScrollPane3 = new JScrollPane();
jScrollPane3.setAutoscrolls(true);
jScrollPane3.getVerticalScrollBar().setSize(17, 48);
jScrollPane3.getHorizontalScrollBar().setEnabled(true);
{
tfExcludeURLsTxt = new JTextArea();
jScrollPane3.setViewportView(tfExcludeURLsTxt);
tfExcludeURLsTxt
.setText("url.http://excludeme.com\r\nurl.http://excludeme2.com"
+ "\r\nelem.footer\r\nelem.header\r\nxlink.;jsessionid");
tfExcludeURLsTxt.setBorder(new LineBorder(new java.awt.Color(0,
0, 0), 1, false));
tfExcludeURLsTxt.setPreferredSize(new java.awt.Dimension(338,
138));
tfExcludeURLsTxt.addMouseListener(new MouseAdapter() {
@Override
public void mousePressed(MouseEvent e) {
tfExcludeURLsTxt.selectAll();
}
});
}
}
jLabel8.setText("Platform:");
jLabel8.setSize(85, 16);
jLabel8.setHorizontalTextPosition(SwingConstants.RIGHT);
jLabel8.setHorizontalAlignment(SwingConstants.RIGHT);
// read the project list from profile.xml
String[] prjList = (new ProfilesXML()).getProjects();
ddlPlatform.setModel(new javax.swing.DefaultComboBoxModel(prjList));
ddlPlatform.addActionListener(new java.awt.event.ActionListener() {
@Override
public void actionPerformed(java.awt.event.ActionEvent evt) {
ddlPlatformActionPerformed(evt);
}
});
cbTakeScreenshots
.setText("Take screenshots (if not selected => crawl only)");
cbTakeScreenshots
.addActionListener(new java.awt.event.ActionListener() {
@Override
public void actionPerformed(java.awt.event.ActionEvent evt) {
cbTakeScreenshotsActionPerformed(evt);
}
});
{
jMenuBar1 = new JMenuBar();
setJMenuBar(jMenuBar1);
{
jMenu1 = new JMenu();
jMenuBar1.add(jMenu1);
jMenu1.setText("Config");
jMenu1.add(getJMenuItem1());
}
{
jMenu2 = new JMenu();
jMenuBar1.add(jMenu2);
jMenu2.setText("About");
{
aboutme = new JMenuItem();
jMenu2.add(aboutme);
aboutme.setText("Credentials");
aboutme.setAction(getHelp());
}
}
}
pack();
this.setSize(771, 638);
}// </editor-fold>//GEN-END:initComponents
private void bGoActionPerformed(java.awt.event.ActionEvent evt) {// GEN-FIRST:event_bGoActionPerformed
if (tfUsername.getText() != null && tfPassword.getText() != null
&& directoryPath != null && taPath.getText() != null
&& tfStartLink.getText() != null
&& tfBaseURLTxt.getText() != null
&& tfExcludeURLsTxt.getText() != null) {
rt = new StartRun(tfUsername.getText(), tfPassword.getText(),
Integer.parseInt(tfPort.getText()), ddlBrowser
.getSelectedItem().toString(), directoryPath,
tfStartLink.getText(),
(String) (ddlPlatform.getSelectedItem()), TAKESCREENSHOTS,
tfBaseURLTxt.getText(), tfExcludeURLsTxt.getText());
rt.start();
} else {
}
}// GEN-LAST:event_bGoActionPerformed
private void bStopActionPerformed(java.awt.event.ActionEvent evt) {// GEN-FIRST:event_bStopActionPerformed
if (rt != null) {
try {
rt.stopTest();
} catch (Exception ex) {
Logger.getLogger(UserInterface.class.getName()).log(
Level.SEVERE, null, ex);
}
}
}// GEN-LAST:event_bStopActionPerformed
private void tfUsernameActionPerformed(java.awt.event.ActionEvent evt) {// GEN-FIRST:event_tfUsernameActionPerformed
// TODO add your handling code here:
}// GEN-LAST:event_tfUsernameActionPerformed
private void tfPasswordActionPerformed(java.awt.event.ActionEvent evt) {// GEN-FIRST:event_tfPasswordActionPerformed
// TODO add your handling code here:
}// GEN-LAST:event_tfPasswordActionPerformed
private void bBrowseActionPerformed(java.awt.event.ActionEvent evt) {// GEN-FIRST:event_bBrowseActionPerformed
// TODO add your handling code here:
JFileChooser jfc = new JFileChooser();
jfc.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
jfc.setDialogTitle("Choose folder");
if (jfc.showOpenDialog(this) == JFileChooser.APPROVE_OPTION) {
directoryPath = jfc.getSelectedFile().getAbsolutePath();
taPath.setText(directoryPath);
} else {
directoryPath = null;
taPath.setText("No Path was chosen");
}
}// GEN-LAST:event_bBrowseActionPerformed
private void setPlatformText() {
selectedPlatform = ddlPlatform.getSelectedItem().toString();
// repeat this as many times as you desire.
// if (selectedPlatform.equals("Subproject1"))
// tfPlatform.setText("https://give-specific-address.com");
// load settings from profile.xml
UIProfile uip = new ProfilesXML().getProject(selectedPlatform);
/*
* System.out.println(uip.getStartLink());
* System.out.println(uip.getBaseURL());
* System.out.println(uip.getExcludes());
* System.out.println(uip.getScreenPath());
*/
tfStartLink.setText(uip.getStartLink());
tfBaseURLTxt.setText(uip.getBaseURL());
tfExcludeURLsTxt.setText(uip.getExcludes());
if ((uip.getScreenPath() != null) && (uip.getScreenPath().length() > 0)) {
cbTakeScreenshots.setSelected(true);
taPath.setText(uip.getScreenPath());
directoryPath = uip.getScreenPath();
this.TAKESCREENSHOTS = 1;
}
}
private void ddlPlatformActionPerformed(java.awt.event.ActionEvent evt) {// GEN-FIRST:event_ddlPlatformActionPerformed
// TODO add your handling code here:
setPlatformText();
}// GEN-LAST:event_ddlPlatformActionPerformed
private void cbTakeScreenshotsActionPerformed(java.awt.event.ActionEvent evt) {// GEN-FIRST:event_cbTakeScreenshotsActionPerformed
// TODO add your handling code here:
if (cbTakeScreenshots.isSelected()) {
TAKESCREENSHOTS = 1;
} else {
TAKESCREENSHOTS = 0;
}
}// GEN-LAST:event_cbTakeScreenshotsActionPerformed
private AbstractAction getHelp() {
if (Help == null) {
Help = new AbstractAction("UI Checker Info", null) {
@Override
public void actionPerformed(ActionEvent evt) {
getAbout().pack();
getAbout().setVisible(true);
}
};
}
return Help;
}
private JDialog getAbout() {
if (About == null) {
About = new JDialog(this);
About.getContentPane().setLayout(null);
About.setPreferredSize(new java.awt.Dimension(573, 380));
About.getContentPane().setBackground(
new java.awt.Color(255, 255, 255));
About.setTitle("UI Checker Info");
About.getContentPane().add(getJPanel2());
About.setSize(573, 380);
}
return About;
}
private JLabel getJLabel12() {
if (jLabel12 == null) {
BufferedImage myPicture = null;
try {
//System.out.println(new File("/bild/usability-testing.png"));
myPicture = ImageIO.read(new File(SetupEnv.getBaseDir() +
"/conf/bild/usability-testing.png"));
} catch (Exception e) {
e.printStackTrace();
}
jLabel12 = new JLabel(new ImageIcon(myPicture));
jLabel12.setBounds(10, 40, 246, 251);
jLabel12.setBorder(BorderFactory
.createEtchedBorder(BevelBorder.LOWERED));
}
return jLabel12;
}
private JLabel getJLabel13() {
if (jLabel13 == null) {
jLabel13 = new JLabel();
jLabel13.setText("Created and maintained by:");
jLabel13.setBounds(217, 18, 191, 264);
jLabel13.setForeground(new java.awt.Color(255, 255, 128));
jLabel13.setPreferredSize(new java.awt.Dimension(168, 22));
}
return jLabel13;
}
private JPanel getJPanel1() {
if (jPanel1 == null) {
jPanel1 = new JPanel();
jPanel1.setBounds(266, 7, 265, 324);
jPanel1.setBackground(new java.awt.Color(128, 64, 64));
jPanel1.setBorder(BorderFactory
.createEtchedBorder(BevelBorder.LOWERED));
jPanel1.add(getJLabel13());
jPanel1.add(getJTextArea2());
}
return jPanel1;
}
private JTextArea getJTextArea2() {
if (jTextArea2 == null) {
jTextArea2 = new JTextArea();
jTextArea2.setText("Ciprian Baltatescu\n" + "Enache Tudor\n"
+ "Mihai Barcun");
jTextArea2.setPreferredSize(new java.awt.Dimension(234, 276));
jTextArea2.setBackground(new java.awt.Color(255, 255, 128));
}
jTextArea2.setOpaque(true);
jTextArea2.setEditable(false);
jTextArea2.setFont(new java.awt.Font("Andalus", 1, 16));
return jTextArea2;
}
private JPanel getJPanel2() {
if (jPanel2 == null) {
jPanel2 = new JPanel();
jPanel2.setBounds(0, 0, 557, 342);
jPanel2.setLayout(null);
jPanel2.add(getJLabel12());
jPanel2.add(getJPanel1());
}
return jPanel2;
}
private JDialog getJDialog1() {
if (AddConfig == null) {
AddConfig = new JDialog(this);
AddConfig.setPreferredSize(new java.awt.Dimension(528, 120));
AddConfig.setTitle("UI Checker - Add new profile");
AddConfig.setLocationByPlatform(true);
AddConfig.setLocation(new java.awt.Point(400, 400));
AddConfig.getContentPane().add(getJPanel3(), BorderLayout.CENTER);
AddConfig.setSize(528, 120);
}
return AddConfig;
}
private JPanel getJPanel3() {
if (jPanel3 == null) {
jPanel3 = new JPanel();
jPanel3.setPreferredSize(new java.awt.Dimension(512, 45));
jPanel3.add(getJLabel14());
jPanel3.add(getJTextField1());
jPanel3.add(getJButton1());
}
return jPanel3;
}
private JTextField getJTextField1() {
if (newSubproject == null) {
newSubproject = new JTextField();
newSubproject.setPreferredSize(new java.awt.Dimension(203, 28));
}
return newSubproject;
}
private JLabel getJLabel14() {
if (jLabel14 == null) {
jLabel14 = new JLabel();
jLabel14.setText("Name of the project:");
}
return jLabel14;
}
private JButton getJButton1() {
if (jButton1 == null) {
jButton1 = new JButton();
jButton1.setText("add profile");
jButton1.addMouseListener(new MouseAdapter() {
@Override
public void mouseClicked(MouseEvent evt) {
jButton1MouseClicked(evt);
}
});
}
return jButton1;
}
private JMenuItem getJMenuItem1() {
if (jMenuItem1 == null) {
jMenuItem1 = new JMenuItem();
jMenuItem1.setText("jMenuItem1");
jMenuItem1.setAction(getAddNewProfile());
}
return jMenuItem1;
}
private AbstractAction getAddNewProfile() {
if (addNewProfile == null) {
addNewProfile = new AbstractAction("Add..", null) {
@Override
public void actionPerformed(ActionEvent evt) {
getJDialog1().pack();
getJDialog1().setVisible(true);
}
};
}
return addNewProfile;
}
private void jButton1MouseClicked(MouseEvent evt) {
System.out.println("jButton1.mouseClicked, event=" + evt);
System.out.println("Hello saving, please wait.."
+ newSubproject.getText());
saveProfileData(newSubproject.getText());
getJDialog1().dispose();
// TODO add your code for jButton1.mouseClicked
}
/*
* saving to xml
*/
private void saveProfileData(String nameSp) {
String startLink = tfStartLink.getText();
String baseURL = tfBaseURLTxt.getText();
String excludes = tfExcludeURLsTxt.getText();
String screenPath = taPath.getText();
System.out.println(nameSp + " " + startLink + " " + baseURL + " "
+ excludes + " " + screenPath);
ProfilesXML pxml = new ProfilesXML(nameSp, startLink, baseURL,
excludes, screenPath);
pxml.writeIN();
}
private void runCMD_Mode(String selectedPlatform, String xBrowser,
int screens) {
UIProfile uip = new ProfilesXML().getProject(selectedPlatform);
tfStartLink.setText(uip.getStartLink());
tfBaseURLTxt.setText(uip.getBaseURL());
tfExcludeURLsTxt.setText(uip.getExcludes());
if ((uip.getScreenPath() != null) && (uip.getScreenPath().length() > 0)) {
cbTakeScreenshots.setSelected(true);
taPath.setText(uip.getScreenPath());
directoryPath = uip.getScreenPath();
this.TAKESCREENSHOTS = screens;
}
rt = new StartRun(tfUsername.getText(), tfPassword.getText(),
Integer.parseInt(tfPort.getText()), xBrowser, directoryPath,
tfStartLink.getText(), selectedPlatform, TAKESCREENSHOTS,
tfBaseURLTxt.getText(), tfExcludeURLsTxt.getText());
rt.setOneTimeRun(1);
rt.start();
}
/**
* @param args
* the command line arguments
*/
public static void main(String args[]) {
boolean b = false;
String selectedPlatform = "General";
String xBrowser = "*firefox";
int screens = 0;
if (args.length == 3) {
System.out.println("Program running in command line mode \n");
b = true;
} else {
System.out
.println("CMD: java -jar UIChecker.jar [profile] [browser] [screenshots]"
+ "\n [profile] - profile saved in profiles.xml"
+ "\n [browser] - selenium client running given browser"
+ "\n [screenshots - take screenshots (1) or not (0)]");
}
if (!b) {
java.awt.EventQueue.invokeLater(new Runnable() {
@Override
public void run() {
new UserInterface().setVisible(true);
}
});
} else {
selectedPlatform = args[0];
xBrowser = args[1];
screens = Integer.parseInt(args[2]);
new UserInterface()
.runCMD_Mode(selectedPlatform, xBrowser, screens);
}
}
// Variables declaration - do not modify//GEN-BEGIN:variables
private javax.swing.JButton bBrowse;
private javax.swing.JButton bGo;
private AbstractAction addNewProfile;
private javax.swing.JButton bStop;
private javax.swing.JCheckBox cbTakeScreenshots;
private javax.swing.JComboBox ddlBrowser;
private javax.swing.JComboBox ddlPlatform;
private javax.swing.JLabel jLabel1;
private javax.swing.JLabel jLabel2;
private javax.swing.JLabel jLabel3;
private javax.swing.JLabel jLabel4;
private javax.swing.JLabel jLabel5;
private javax.swing.JLabel jLabel6;
private javax.swing.JLabel jLabel7;
private javax.swing.JLabel jLabel8;
private javax.swing.JScrollPane jScrollPane1;
private javax.swing.JScrollPane jScrollPane2;
private javax.swing.JTextArea jTextArea1;
private javax.swing.JTextArea taPath;
private javax.swing.JTextField tfPassword;
private javax.swing.JTextField tfStartLink;
private javax.swing.JTextField tfPort;
private javax.swing.JTextField tfUsername;
// End of variables declaration//GEN-END:variables
}