/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
/*
* muralha.java
*
* Created on 22/10/2009, 19:17:14
*/
package br.uff.ic.gems.ourico.Interface;
import br.uff.ic.oceano.core.exception.ServiceException;
import br.uff.ic.oceano.ourico.checkout.ciclo.CheckoutCiclo;
import br.uff.ic.oceano.ourico.model.CheckOut;
import br.uff.ic.oceano.ourico.rcs.context.Constants;
import br.uff.ic.oceano.ourico.service.ClientService;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.swing.JFileChooser;
import javax.swing.JOptionPane;
import org.tmatesoft.svn.core.SVNException;
/**
*
* @author marapao
*/
public class muralha extends javax.swing.JFrame {
/** Creates new form muralha */
public muralha() {
initComponents();
}
/** 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.
*/
// <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
private void initComponents() {
jPanel1 = new javax.swing.JPanel();
jLabel1 = new javax.swing.JLabel();
tfLogin = new javax.swing.JTextField();
jLabel4 = new javax.swing.JLabel();
pwfSenha = new javax.swing.JPasswordField();
jPanel2 = new javax.swing.JPanel();
jLabel2 = new javax.swing.JLabel();
tfCheckOutUrl = new javax.swing.JTextField();
jLabel3 = new javax.swing.JLabel();
tfCheckOutWorkspace = new javax.swing.JTextField();
btnProcuraWorkspace = new javax.swing.JButton();
jButton2 = new javax.swing.JButton();
setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
addWindowListener(new java.awt.event.WindowAdapter() {
public void windowOpened(java.awt.event.WindowEvent evt) {
inicializaJPA(evt);
}
});
jPanel1.setBorder(javax.swing.BorderFactory.createTitledBorder("Dados do Usuário"));
jLabel1.setText("Login");
tfLogin.setText("ourico");
jLabel4.setText("Senha");
pwfSenha.setText("TerdOckpic8");
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(jLabel1)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(tfLogin, javax.swing.GroupLayout.PREFERRED_SIZE, 186, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(18, 18, 18)
.addComponent(jLabel4)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(pwfSenha, javax.swing.GroupLayout.DEFAULT_SIZE, 186, Short.MAX_VALUE)
.addContainerGap())
);
jPanel1Layout.setVerticalGroup(
jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel1Layout.createSequentialGroup()
.addContainerGap()
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jLabel1)
.addComponent(tfLogin, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jLabel4)
.addComponent(pwfSenha, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
);
jPanel2.setBorder(javax.swing.BorderFactory.createTitledBorder("Check-out"));
jLabel2.setText("URL repositório");
tfCheckOutUrl.setText("https://gems.ic.uff.br/svn/testeourico/trunk");
tfCheckOutUrl.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
tfCheckOutUrlActionPerformed(evt);
}
});
jLabel3.setText("Path workspace");
tfCheckOutWorkspace.setText("/home/marapao/Desktop/sandbox");
btnProcuraWorkspace.setText("Procurar");
btnProcuraWorkspace.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
btnProcuraWorkspaceActionPerformed(evt);
}
});
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(jPanel2Layout.createSequentialGroup()
.addContainerGap()
.addComponent(jLabel3))
.addGroup(jPanel2Layout.createSequentialGroup()
.addGap(12, 12, 12)
.addComponent(jLabel2)))
.addGap(18, 18, 18)
.addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel2Layout.createSequentialGroup()
.addComponent(tfCheckOutWorkspace, javax.swing.GroupLayout.DEFAULT_SIZE, 315, Short.MAX_VALUE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addComponent(btnProcuraWorkspace))
.addComponent(tfCheckOutUrl, javax.swing.GroupLayout.DEFAULT_SIZE, 393, Short.MAX_VALUE))
.addContainerGap())
);
jPanel2Layout.setVerticalGroup(
jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel2Layout.createSequentialGroup()
.addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(tfCheckOutUrl, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jLabel2))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(tfCheckOutWorkspace, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jLabel3)
.addComponent(btnProcuraWorkspace))
.addContainerGap(22, Short.MAX_VALUE))
);
jButton2.setText("Fazer check-out");
jButton2.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton2ActionPerformed(evt);
}
});
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
getContentPane().setLayout(layout);
layout.setHorizontalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addContainerGap()
.addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGroup(layout.createSequentialGroup()
.addGap(203, 203, 203)
.addComponent(jButton2))
.addComponent(jPanel2, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
.addContainerGap())
);
layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addContainerGap()
.addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(35, 35, 35)
.addComponent(jPanel2, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addGap(18, 18, 18)
.addComponent(jButton2)
.addContainerGap())
);
jPanel1.getAccessibleContext().setAccessibleName("Dados Usuário");
pack();
}// </editor-fold>//GEN-END:initComponents
private void btnProcuraWorkspaceActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnProcuraWorkspaceActionPerformed
// TODO add your handling code here:
JFileChooser caminho = new JFileChooser();
caminho.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
if (caminho.showOpenDialog(this) == javax.swing.JFileChooser.APPROVE_OPTION) {
tfCheckOutWorkspace.setText(caminho.getSelectedFile().toString());
}
}//GEN-LAST:event_btnProcuraWorkspaceActionPerformed
private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton2ActionPerformed
try {
// TODO add your handling code here:
/************************************Dados que virão do BD ******************************************/
//Estou assumindo essta estrutura por enquanto:
//pathRepositorio + dirAutobranch = pathAutobranch
//pathRepositorio + dirProtegido = pathProtegido
String dirAutobranch = "/autobranch/";
String dirProtegido = "/trunk/";
String politica = "restritiva";
String Projeto = "testando";
/************************************Fim dados que virão do BD ******************************************/
// CheckOut co = new CheckOut();
// CheckOutService checkOutService = ObjectFactory.getObj(CheckOutService.class);
ClientService clientService = new ClientService();
Long revisao;
String urlCheckout;
String login;
String senha;
String workspace = null;
if (tfCheckOutUrl.getText().isEmpty()) {
JOptionPane.showMessageDialog(null, "Favor preencher o URL.", "Campo Vazio.", JOptionPane.ERROR_MESSAGE);
return;
} else {
urlCheckout = tfCheckOutUrl.getText();
}
if (tfCheckOutWorkspace.getText().isEmpty()) {
JOptionPane.showMessageDialog(null, "Favor preencher o Workspace.", "Campo Vazio.", JOptionPane.ERROR_MESSAGE);
return;
} else {
workspace = tfCheckOutWorkspace.getText();
}
if (tfLogin.getText().isEmpty()) {
JOptionPane.showMessageDialog(null, "Favor preencher o Login.", "Campo Vazio.", JOptionPane.ERROR_MESSAGE);
return;
} else {
login = tfLogin.getText();
}
if (pwfSenha.getText().isEmpty()) {
JOptionPane.showMessageDialog(null, "Favor preencher o Senha.", "Campo Vazio.", JOptionPane.ERROR_MESSAGE);
return;
} else {
senha = pwfSenha.getText();
}
String url = Constants.URL_OCEANO;
CheckoutCiclo checkoutCiclo = new CheckoutCiclo();
try {
CheckOut remoto = checkoutCiclo.remoto(urlCheckout, senha, login, workspace, url);
JOptionPane.showMessageDialog(null, "Checkout foi realizado para " + workspace + "/" + remoto.getAutobranch(), "Checkout concluido", JOptionPane.INFORMATION_MESSAGE);
} catch (SVNException ex) {
JOptionPane.showMessageDialog(null, "Falha ao realizar checkout de "+url +"\n"+ex.getMessage(), "Falha no Checkout", JOptionPane.ERROR_MESSAGE);
Logger.getLogger(muralha.class.getName()).log(Level.SEVERE, null, ex);
}
} catch (ServiceException ex) {
System.out.println("Problema durante a execução do método preparaAutobranch.");
System.out.println(ex.getMessage());
Logger.getLogger(muralha.class.getName()).log(Level.SEVERE, null, ex);
}
}//GEN-LAST:event_jButton2ActionPerformed
private void tfCheckOutUrlActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_tfCheckOutUrlActionPerformed
// TODO add your handling code here:
}//GEN-LAST:event_tfCheckOutUrlActionPerformed
private void inicializaJPA(java.awt.event.WindowEvent evt) {//GEN-FIRST:event_inicializaJPA
// TODO add your handling code here:
}//GEN-LAST:event_inicializaJPA
/**
* @param args the command line arguments
*/
public static void main(String args[]) {
java.awt.EventQueue.invokeLater(new Runnable() {
public void run() {
new muralha().setVisible(true);
}
});
}
// Variables declaration - do not modify//GEN-BEGIN:variables
private javax.swing.JButton btnProcuraWorkspace;
private javax.swing.JButton jButton2;
private javax.swing.JLabel jLabel1;
private javax.swing.JLabel jLabel2;
private javax.swing.JLabel jLabel3;
private javax.swing.JLabel jLabel4;
private javax.swing.JPanel jPanel1;
private javax.swing.JPanel jPanel2;
private javax.swing.JPasswordField pwfSenha;
private javax.swing.JTextField tfCheckOutUrl;
private javax.swing.JTextField tfCheckOutWorkspace;
private javax.swing.JTextField tfLogin;
// End of variables declaration//GEN-END:variables
}