Package

Source Code of SVNComandoLogMerge$MergeLogFrame

import java.awt.BorderLayout;
import java.awt.event.ActionEvent;
import java.awt.event.KeyEvent;

import javax.swing.AbstractAction;
import javax.swing.JComponent;
import javax.swing.JFrame;
import javax.swing.JScrollPane;
import javax.swing.JTextPane;
import javax.swing.KeyStroke;

import org.jdesktop.swingx.JXFrame;

import es.juanrak.svn.cnf.SVNError;
import es.juanrak.svn.modelo.SVNLogEntrada;
import es.juanrak.svn.plugin.SVNJavaPlugin;

public class SVNComandoLogMerge extends SVNJavaPlugin {

    public void ejecutar(SVNLogEntrada logEntradaRecibo) {
      if( logEntradaRecibo != null ) {
        MergeLogFrame mergeLogFrame = new MergeLogFrame();
        mergeLogFrame.setTitle("Merge hasta revision: " + logEntradaRecibo.getParaPath());
        mergeLogFrame.setVisible(true);
       
       
        StringBuffer buffer = new StringBuffer("MERGE: Merge realizado desde ");
        buffer.append( getRutaMerge(logEntradaRecibo) );
        buffer.append(" de ");
        buffer.append(getRevisionPrevia(logEntradaRecibo));
        buffer.append(" a ").append(logEntradaRecibo.getRevision());
        buffer.append("\n------------------------------------------------------------------------\n");
        {
          buffer.append(logEntradaRecibo.getRevision()).append(" | ");
          buffer.append(logEntradaRecibo.getAutor()).append(" | ");
          java.text.DateFormat sdf = new java.text.SimpleDateFormat("hh:mm dd/MM/yyyy");
          buffer.append(sdf.format(logEntradaRecibo.getFecha()));
          buffer.append(" | Cambios ").append(logEntradaRecibo.getRutasCambiadas().size());
        }
        buffer.append("\n------------------------------------------------------------------------\n");
        buffer.append(logEntradaRecibo.getMensaje());
        mergeLogFrame.textPane.setText(buffer.toString());
      }
    }
   
    private Object getRutaMerge(SVNLogEntrada logEntradaRecibo) {
      String rutaMerge = logEntradaRecibo.getParaPath();
      try {
        rutaMerge = getControlador().getPathAbsoluta(logEntradaRecibo.getParaPath());
        if( rutaMerge != null ) {
          int indiceTrunk = rutaMerge.toUpperCase().lastIndexOf("/TRUNK/");
          int indiceBranch = rutaMerge.toUpperCase().lastIndexOf("/BRANCH/");
          if( indiceTrunk > indiceBranch ) {
            String temporal = rutaMerge.substring(0,indiceTrunk);
            int indiceBarra = temporal.lastIndexOf("/");
            if( indiceBarra != -1) {
              rutaMerge = temporal.substring(indiceBarra+1) + rutaMerge.substring(indiceTrunk+ ("/TRUNK").length() );
            }
            else {
              rutaMerge = rutaMerge.substring(indiceTrunk);
            }
          }
          else if( indiceBranch != -1 ) {
            rutaMerge = rutaMerge.substring(indiceBranch+("/BRANCH").length());
          }

        }
      }
      catch(Exception exception) {
        getControlador().getLogger().error(SVNError.getError(SVNError.ERROR_OBTENER_LOG, exception));
      }
      return rutaMerge;
  }

  private long getRevisionPrevia(SVNLogEntrada logEntradaRecibo) {
      try {
        SVNLogEntrada logEntrada = getControlador().logAnterior(logEntradaRecibo.getParaPath(), logEntradaRecibo.getRevision());
        if( logEntrada != null ) {
          return logEntrada.getRevision();
        }
      }
      catch(Exception exception) {
        getControlador().getLogger().error(SVNError.getError(SVNError.ERROR_OBTENER_LOG, exception));
      }
      return 0;
    }
   
    public class MergeLogFrame extends JXFrame {
      JTextPane textPane = new JTextPane();
      public MergeLogFrame() {
        initComponents();
        setSize(500, 400);
      }
      private void initComponents() {
            getRootPane().getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0), "ESCAPE");
            getRootPane().getActionMap().put("ESCAPE", new AbstractAction() {
                public void actionPerformed(ActionEvent e) {
                    dispose();
                }
            });
           
        JScrollPane scrollPanel = new JScrollPane(textPane);
        setLayout(new BorderLayout());
        add(scrollPanel);
       
        setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
      }
    }
}
TOP

Related Classes of SVNComandoLogMerge$MergeLogFrame

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.