package gov.nasa.jpl.mbee.ems.validation.actions;

import gov.nasa.jpl.mbee.lib.Utils;
import gov.nasa.jpl.mgss.mbee.docgen.validation.IRuleViolationAction;
import gov.nasa.jpl.mgss.mbee.docgen.validation.RuleViolationAction;

import java.awt.event.ActionEvent;
import java.util.Collection;

import javax.swing.JDialog;
import javax.swing.JScrollPane;
import javax.swing.JSplitPane;
import javax.swing.JTextArea;


import org.json.simple.JSONObject;

import com.nomagic.magicdraw.annotation.Annotation;
import com.nomagic.magicdraw.annotation.AnnotationAction;
import com.nomagic.magicdraw.ui.dialogs.MDDialogParentProvider;
import com.nomagic.uml2.ext.jmi.helpers.ModelHelper;
import com.nomagic.uml2.ext.magicdraw.classes.mdkernel.Element;

public class CompareText extends RuleViolationAction implements AnnotationAction, IRuleViolationAction {

    private static final long serialVersionUID = 1L;
    private Element element;
    private String webDoc;
    private String modelDoc;
    private JSONObject result;
    
    public CompareText(Element e, String web, String model, JSONObject result) {
        super("Compare Text", "Compare Text", null, null);
        this.element = e;
        this.webDoc = web;
        this.modelDoc = model;
        this.result = result;
    }
    
    @Override
    public boolean canExecute(Collection<Annotation> arg0) {
        return false;
    }

    @Override
    public void execute(Collection<Annotation> annos) {
        
    }
    
    @Override
    public void actionPerformed(ActionEvent e) {
        JTextArea web = new JTextArea(webDoc);
        web.setEditable(false);
        web.setLineWrap(true);
        JTextArea model = new JTextArea(modelDoc);
        model.setEditable(false);
        model.setLineWrap(true);
        JScrollPane webp = new JScrollPane(web);
        webp.setName("Web");
        JScrollPane modelp = new JScrollPane(model);
        modelp.setName("Model");
        JSplitPane top = new JSplitPane();
        
        JDialog show = new JDialog(MDDialogParentProvider.getProvider().getDialogParent());
        show.setTitle("Comparison");
        show.setSize(600, 600);
        show.getContentPane().add(top);
        top.setDividerLocation(.5);
        top.setLeftComponent(modelp);
        top.setRightComponent(webp);
        show.setVisible(true);
    }

}

@@ -372,24 +372,56 @@
 JSplitPane;%0A
+import javax.swing.JTabbedPane;%0A
 import javax
@@ -1566,24 +1566,124 @@
 nEvent e) %7B%0A
+        JTabbedPane webpane = new JTabbedPane();%0A        JTabbedPane modelpane = new JTabbedPane();%0A
         JTex
@@ -1713,24 +1713,24 @@
 ea(webDoc);%0A
-
         web.
@@ -1972,24 +1972,61 @@
 ame(%22Web%22);%0A
+        webpane.addTab(%22Web%22, webp);%0A
         JScr
@@ -2095,24 +2095,67 @@
 e(%22Model%22);%0A
+        modelpane.addTab(%22Model%22, modelp);%0A
         JSpl
@@ -2462,24 +2462,27 @@
 onent(modelp
+ane
 );%0A        t
@@ -2502,24 +2502,27 @@
 mponent(webp
+ane
 );%0A        s

add visual feedback in text comparison pane for which side is which