//
// Mining module for TETDM 
// SourceRead Version 0.37
// Copyright(C) 2012 Wataru Sunayama

// You should read the README file.
//

package module.MiningModules.SourceRead;

import source.*;
import source.TextData.*;
//import source.Utility.*;

import java.io.*;

import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import javax.swing.event.*;

import java.util.*;

public class SourceRead extends MiningModule implements ActionListener,FocusListener
{
	String modulePath;	
	String moduleName;

	String source[];
	String basicFunctions[];
	String dataSupply;

	
	String dataSet;
	String dataRequest[];
    
	String focusWords[];
	String focusVariables[];	
	String focusFunctions[];
	String focusFunctions2[];
    
	String optionRequests[];
	String optionRequests2[];

	String warnings;
	String readme;
	
	boolean mining;
	
    JToggleButton button[];
	int buttonNumber;
	ButtonGroup buttonGroup;
	
	JComboBox miningSelect;
	JComboBox visualizationSelect;
	int visualizationToIndex[];
	int indexToVisualization[];	
	int selectedMining;
	int selectedVisualization;
	
	String moduleNames[];
	String moduleNamesInJapanese[];
	String visuModuleNames[];
	String visuModuleNamesInJapanese[];
    int miningDisplayOrderIndex[];
    int miningDisplayOrderReverseIndex[];
    int visualizationDisplayOrderIndex[];
	
	int moduleNumber;
	int visuModuleNumber;
	
	boolean autoSet;
	

	

	//////////////////////
	void initializeMiningComboBox()
	{
		String names[] = new String[moduleNumber];
		
        miningDisplayOrderIndex = text.control.moduleData.miningDisplayOrderIndex;
        miningDisplayOrderReverseIndex = text.control.moduleData.miningDisplayOrderReverseIndex;
        
		if(text.control.sp1.inJapanese)
			for(int i=0;i<moduleNumber;i++)
				names[i] = moduleNamesInJapanese[miningDisplayOrderIndex[i]];
		else
			for(int i=0;i<moduleNumber;i++)			
				names[i] = moduleNames[miningDisplayOrderIndex[i]];

		miningSelect = new JComboBox(names);
		selectedMining = text.control.moduleData.findModule(getModuleID());
		miningSelect.setSelectedIndex(miningDisplayOrderReverseIndex[selectedMining]);
		miningSelect.addActionListener(this);
		miningSelect.addFocusListener(this);
		miningSelect.setMaximumRowCount(50);
		operationPanel.add(miningSelect);		
	}
	
	void initializeVisualizationComboBox()
	{
		String names[] = new String[visuModuleNumber];
		
        visualizationDisplayOrderIndex = text.control.moduleData.visualizationDisplayOrderIndex;
        
		if(text.control.sp1.inJapanese)	
			for(int i=0;i<visuModuleNumber;i++)
				names[i] = visuModuleNamesInJapanese[visualizationDisplayOrderIndex[i]];
		else
			for(int i=0;i<visuModuleNumber;i++)			
				names[i] = visuModuleNames[visualizationDisplayOrderIndex[i]];
		
		visualizationSelect = new JComboBox(names);
		selectedVisualization = -1;		
		visualizationSelect.setSelectedIndex(selectedVisualization);
		visualizationSelect.addActionListener(this);
		visualizationSelect.addFocusListener(this);
		visualizationSelect.setMaximumRowCount(50);		
		operationPanel.add(visualizationSelect);
	}		
	
	public SourceRead()
	{
		setModuleID(99999);						// Set your module ID after you have got it
		setCategoryID(8);
		pairingVisualizationID = new int[]{1};
		setToolType(2);
	}

	public void initializePanel()
	{
		operationPanel.setLayout(new GridLayout(2,5));		
		
		String buttonNames[] = {"Source","Constructor","Global","Basic","Check","Readme"};

		buttonNumber = 6;
		button = new JToggleButton[buttonNumber];		


		operationPanel.setBackground(Color.RED);

		buttonGroup = new ButtonGroup();
		for(int i=0;i<buttonNumber;i++)
		{
			button[i] = new JToggleButton(buttonNames[i]);
			button[i].setBackground(Color.RED);
			button[i].addActionListener(this);
			operationPanel.add(button[i]);
			
			buttonGroup.add(button[i]);
		}
		button[5].setSelected(true);
		
		if(isMenuInJapanese())
			for(int i=0;i<buttonNumber;i++)
				button[i].setText(inJapanese[17+i]);
		
		moduleNames = text.control.moduleData.module_names;
		moduleNamesInJapanese = text.control.moduleData.miningModuleNamesInJapanese;
		moduleNumber = moduleNames.length;
		
		visuModuleNames = text.control.moduleData.visu_module_names;
		visuModuleNamesInJapanese = text.control.moduleData.visualizationModuleNamesInJapanese;
		visuModuleNumber = visuModuleNames.length;
		
		initializeMiningComboBox();
		initializeVisualizationComboBox();
	}

    public void initializeData()
    {
		mining = true;
		autoSet = false;
		
		moduleName = myModuleName;
		modulePath = myModulePath;
		source = fileReadArray(myModulePath+myModuleName+".java");
		
		for(int i=0;i<source.length;i++)
			source[i] = source[i].replaceAll("	","    ");
		
		basicFunctions = new String[]{"initializePanel(","initializeData(","miningOperations(","displayOperations(","additionalPanelSet("};
		dataSupply = "setData";

		focusWords = new String[]{"focusKeywords","focusSegments","focusSentences",
            "mainFocusKeyword","subFocusKeyword","mainFocusSegment","subFocusSegment","mainFocusSentence","subFocusSentence",
            "mainFocusString","subFocusString","mainFocusDouble","subFocusDouble","mainFocusInteger","subFocusInteger"};
//        focusVariables = new String[]{"focusExecute","focusClickExecute"};//////////
//        focusFunctions = new String[]{"repaintOthersByFocus(","repaintOthersByClick("};//////////
//        focusFunctions2 = new String[]{"executeAllByFocus","executeAllByClick","executeOthersByFocus","executeOthersByClick"};//////////
        
        focusVariables = new String[]{"focusExecute"};//////////
        focusFunctions = new String[]{"repaintOthersByFocus("};//////////
        focusFunctions2 = new String[]{"executeAllByFocus","executeOthersByFocus"};//////////
        
        optionRequests = new String[]{"displayOtherModule(","displayOtherModuleFirst(","displayModule(","displayModuleFirst(",};
        optionRequests2 = new String[]{"executeOtherModule(","executeOtherModuleFirst(","executeModule(","executeModuleFirst("};
        
		dataRequest = new String[]{"getData","getNewData"};
        
		
		//global variables		//should not have right value if indexOf("=") > 0 -> OUT
		System.out.println("MODULE PATH"+modulePath);
		System.out.println("MODULE Name"+moduleName);		
		//
    }
	
    public void miningOperations(int optionNumber)
	{
	    switch(optionNumber)
		{
            case 0:miningOperations(5);
                break;
                
			case 6://source
                resetData();
				setDataString(sourceText());
				break;

			case 1://constructor
                resetData();
				setDataString(extractConstructor(moduleName));
				break;

			case 2://global variables
                resetData();
				setDataString(extractGlobalAreas());
				break;

			case 3://basic functions
                resetData();
				setDataString(extractFunctions(basicFunctions));
				break;

			case 4://check
                resetData();
				setDataString(checkWarnings());
				break;

			case 5://save readme.txt
                String readmeText="";
				
				readmeText += (inJapanese[29]+inJapanese[32]+System.getProperty("line.separator"));
				readmeText += createReadmeForCommonContents();				
				
                if(mining)
                    readmeText += createReadmeForMiningModule();                    
                else
                    readmeText += createReadmeForVisualizationModule();

                resetData();
                setDataString(readmeText);
				break;		
		}
	}
	
	String checkWarnings()
	{
		warnings = "";
		
		extractGlobalAreas();
		
		if(warnings.equals(""))
			warnings = inJapanese[8];
		
		return warnings;
	}

    String createReadmeForCommonContents()
    {
		StringWriter sw = new StringWriter();			//For words
		BufferedWriter bw = new BufferedWriter(sw);
		
		try{
			bw.newLine();
            bw.write(inJapanese[34]);
            bw.newLine();            
            bw.write(inJapanese[29]+inJapanese[24]);
            bw.newLine();
			bw.newLine();
			bw.newLine();
			
			bw.newLine();
            bw.write(inJapanese[36]);
            bw.newLine();            
            bw.write(inJapanese[29]+inJapanese[38]);
            bw.newLine();
			bw.newLine();
			bw.newLine();  
			
			bw.newLine();
            bw.write(inJapanese[37]);
            bw.newLine();            
            bw.write(inJapanese[29]+inJapanese[39]);
            bw.newLine();
			bw.newLine();
			bw.newLine();  			
			
			bw.newLine();
            bw.write(inJapanese[35]);
            bw.newLine();            
            bw.write(inJapanese[29]+inJapanese[33]);
            bw.newLine();
			bw.newLine();
			bw.newLine(); 			
            
            //Author and License
            bw.write(inJapanese[25]);
			bw.newLine();
			bw.newLine();            
            bw.write(inJapanese[26]);
            bw.write(inJapanese[29]);
			bw.newLine();
            bw.write(inJapanese[27]);
			bw.newLine();
			bw.newLine();
			bw.newLine();            
            
            //Developer
            bw.write(inJapanese[28]);
			bw.newLine();
            bw.write("-----");
			bw.newLine();
            
			bw.flush();
		}
		catch(Exception e){
			System.out.println("writing ERROR in SourceRead");
		}
		
		return sw.toString();
    }
    
	String createReadmeForMiningModule()
	{
		StringWriter sw = new StringWriter();			//For words
		BufferedWriter bw = new BufferedWriter(sw);
		String result1,result2;
		
		try{
			bw.write("[README.txt for MINING MODULE]  :  "+moduleName);
			bw.newLine();
			bw.newLine();
			
			bw.write(inJapanese[0]);//miningOperations
			result1 = extractCaseLine(basicFunctions[2]);
			if(result1.equals(""))
				bw.write(inJapanese[8]);
            else
            {
                result1 = result1.replaceAll("    ","");
                bw.newLine();
                bw.write(result1);
				bw.write(inJapanese[29]);
            }
			bw.newLine();
		
			bw.write(inJapanese[1]);//setData
			result1 = extractCalledFunction(dataSupply);
			if(result1.equals(""))
				bw.write(inJapanese[8]);
            else
            {
                result1 = result1.replaceAll("    ","");
                bw.newLine();
                bw.write(result1);
				bw.write(inJapanese[29]);
            }
			bw.newLine();
		
			bw.write(inJapanese[2]);//extend
			result1 = extractClassLine(moduleName);
			if(result1.equals(""))
				bw.write(inJapanese[8]);
            else
            {
                result1 = result1.replaceAll("    ","");
                bw.newLine();
                bw.write(result1);
                bw.newLine();
				bw.write(inJapanese[29]);
            }
			bw.newLine();
		
			bw.write(inJapanese[3]);//focus
			result1 = extractVariables(focusWords);
			if(result1.equals(""))
				bw.write(inJapanese[8]);
			else
            {
                result1 = result1.replaceAll("    ","");
                bw.newLine();
                bw.write(result1);
				bw.write(inJapanese[29]);
                bw.newLine();
            }
			bw.newLine();
			
			bw.write(inJapanese[4]);//focus
			result1 = extractLine(focusVariables[0]);
//			result2 = extractLine(focusVariables[1]);
//            if(result1.equals("") && result2.equals(""))
            if(result1.equals(""))
				bw.write(inJapanese[8]);
            else
            {
                result1 = result1.replaceAll("    ","");
//                result2 = result2.replaceAll("    ","");
                bw.newLine();
                bw.write(result1);
//                bw.write(result2);
                bw.newLine();
				bw.write(inJapanese[29]);
            }
			bw.newLine();

			bw.write(inJapanese[5]);//option visual
			result1 = extractCalledFunctions(optionRequests);
			if(result1.equals(""))
				bw.write(inJapanese[8]);
            else
            {
                result1 = result1.replaceAll("    ","");
                bw.newLine();
                bw.write(result1);
				bw.write(inJapanese[29]);
            }
			bw.newLine();
			
			bw.write(inJapanese[6]);//option mining
			result1 = extractCalledFunctions(optionRequests2);
			if(result1.equals(""))
				bw.write(inJapanese[8]);
            else
            {
                result1 = result1.replaceAll("    ","");
                bw.newLine();
                bw.write(result1);
				bw.write(inJapanese[29]);
            }
			bw.newLine();

			bw.write(inJapanese[7]);//data
			result1 = extractCalledFunction(dataRequest[0]);
			result2 = extractCalledFunction(dataRequest[1]);
			if(result1.equals("") && result2.equals(""))
				bw.write(inJapanese[8]);
            else
            {
                result1 = result1.replaceAll("    ","");
                result2 = result2.replaceAll("    ","");
                bw.newLine();
                bw.write(result1);
                bw.write(result2);
				bw.write(inJapanese[29]);
            }
			bw.newLine();

			bw.flush();
		}			
		catch(Exception e){
			System.out.println("writing ERROR in SourceRead");
		}
		
		return sw.toString();
	}
	
	String createReadmeForVisualizationModule()
	{
		StringWriter sw = new StringWriter();			//For words
		BufferedWriter bw = new BufferedWriter(sw);
		String result1,result2;
		
		try{
			
			bw.write("[README.txt for VISUALIZATION MODULE]  :  "+moduleName);
			bw.newLine();
			bw.newLine();
			
			bw.write(inJapanese[9]);//displayOperations
			result1 = extractCaseLine(basicFunctions[3]);
			if(result1.equals(""))
				bw.write(inJapanese[8]);
            else
            {
                result1 = result1.replaceAll("    ","");
                bw.newLine();
                bw.write(result1);
   				bw.write(inJapanese[29]);
            }
			bw.newLine();
			
			bw.write(inJapanese[10]);//setData
			result1 = extractCaseLines(dataSupply);
			if(result1.equals(""))
				bw.write(inJapanese[8]);
            else
            {
                result1 = result1.replaceAll("    ","");
                bw.newLine();
                bw.write(result1);
   				bw.write(inJapanese[29]);
            }
			bw.newLine();
			
			bw.write(inJapanese[11]);//extend
			result1 = extractClassLine(moduleName);
			if(result1.equals(""))
				bw.write(inJapanese[8]);
            else
            {
                result1 = result1.replaceAll("    ","");
                bw.newLine();
                bw.write(result1);
                bw.newLine();
   				bw.write(inJapanese[29]);
            }
			bw.newLine();
			
			bw.write(inJapanese[12]);//focus
			result1 = extractVariables(focusWords);
			if(result1.equals(""))
				bw.write(inJapanese[8]);
            else
            {
                result1 = result1.replaceAll("    ","");
                bw.newLine();
                bw.write(result1);
                bw.newLine();
   				bw.write(inJapanese[29]);
            }
			bw.newLine();
			
			bw.write(inJapanese[13]);//focus
			result1 = extractCalledFunctions(focusFunctions);
			if(result1.equals(""))
				bw.write(inJapanese[8]);
            else
            {
                result1 = result1.replaceAll("    ","");
                bw.newLine();
                bw.write(result1);
   				bw.write(inJapanese[29]);
            }
			bw.newLine();
			
			bw.write(inJapanese[14]);//focus
			result1 = extractCalledFunctions(focusFunctions2);
			if(result1.equals(""))
				bw.write(inJapanese[8]);
            else
            {
                result1 = result1.replaceAll("    ","");
                bw.newLine();
                bw.write(result1);
   				bw.write(inJapanese[29]);
            }
			bw.newLine();
			
			bw.write(inJapanese[15]);//option visual
			result1 = extractCalledFunctions(optionRequests);
			if(result1.equals(""))
				bw.write(inJapanese[8]);
            else
            {
                result1 = result1.replaceAll("    ","");
                bw.newLine();
                bw.write(result1);
   				bw.write(inJapanese[29]);
            }
			bw.newLine();
			
			bw.write(inJapanese[16]);//option mining
			result1 = extractCalledFunctions(optionRequests2);
			if(result1.equals(""))
				bw.write(inJapanese[8]);
            else
            {
                result1 = result1.replaceAll("    ","");
                bw.newLine();
                bw.write(result1);
   				bw.write(inJapanese[29]);
            }
			bw.newLine();

			bw.flush();
		}			
		catch(Exception e){
			System.out.println("writing ERROR in SourceRead");
		}
		
		return sw.toString();
	}
	
	
	String extractText(String originalText[], int startLine, int endLine)
	{
		StringWriter sw = new StringWriter();			//For words
		BufferedWriter bw = new BufferedWriter(sw);
		
		try{
			for(int i=startLine; i<=endLine; i++)
			{

				bw.write(originalText[i]);
				bw.newLine();
			}
			bw.flush();
		}
		catch(Exception e){
			System.out.println("writing ERROR in SourceRead");
		}		
		
		return sw.toString();			
	}	
	
	String sourceText()
	{
		return extractText(source, 0, source.length-1);	
	}

	int findEndOfFunction(String originalText[], int startLine)
	{
		int count = 0, index, endLine = startLine;
		boolean start = false;
		for(int i=startLine;i<originalText.length;i++)
		{
			index = -1;
			while((index = originalText[i].indexOf("{", index+1)) != -1)
				count++;
			
			if(count > 0)
				start = true;
			
			index = -1;
			while((index = originalText[i].indexOf("}", index+1)) != -1)
				count--;
			
			if(start && count == 0)
			{
				endLine = i;
				break;
			}				
		}
		return endLine;
	}
	
	String extractGlobalAreas()
	{	
		int count = 0, index = -1;		
		StringWriter sw = new StringWriter();			//For words
		BufferedWriter bw = new BufferedWriter(sw);
		
		try{
			for(int i=0;i<source.length;i++)
			{
				if(count == 1)
				{
					bw.write(source[i]);
					bw.newLine();
					
					if(source[i].indexOf("=") != -1)
					{
						warnings += ("LINE "+(i+1)+": Using Right Value");
						warnings += System.getProperty("line.separator");
						warnings += ("You should initialize variables in initializePanel() or initializeData()");
						warnings += System.getProperty("line.separator");						
						warnings += source[i];
						warnings += System.getProperty("line.separator");
						warnings += System.getProperty("line.separator");							
					}
				}
				
				index = -1;
				while((index = source[i].indexOf("{", index+1)) != -1)
					count++;
				
				index = -1;
				while((index = source[i].indexOf("}", index+1)) != -1)
					count--;				
			}
			bw.flush();
		}
		catch(Exception e){
			System.out.println("writing ERROR in SourceRead");
		}		
		
		return sw.toString();		
	}
	
	String extractConstructor(String functionName)
	{
		int startLine=0, endLine=-1;
		
		for(int i=0;i<source.length;i++)
			if(source[i].indexOf(functionName) > 0 && source[i].indexOf("(") != -1 && source[i].indexOf(")") != -1)
			{
				startLine = i;
				break;
			}
		
		if(startLine > 0)
			endLine = findEndOfFunction(source, startLine);
		
		return extractText(source, startLine, endLine);		
	}
	
	String extractClassLine(String functionName)
	{
		String out="";
		
		for(int i=0;i<source.length;i++)
			if(source[i].indexOf(functionName) != -1 && source[i].indexOf("extends") != -1)
			{
				out = source[i];
				break;
			}
		
		return out;
	}	
	
	String extractFunction(String functionName)
	{
		int startLine=0, endLine=-1;
		
		for(int i=0;i<source.length;i++)
			if(source[i].indexOf(functionName) > 0 && source[i].indexOf("void") != -1)
			{
				startLine = i;
				break;
			}
		
		if(startLine > 0)
			endLine = findEndOfFunction(source, startLine);

		return extractText(source, startLine, endLine);
	}
	
	String extractFunctions(String functionNames[])
	{
		String out = "";
		
		for(int i=0;i<functionNames.length;i++)
			out += extractFunction(functionNames[i]);
		
		return out;
	}	
	
	String extractCaseLine(String functionName)
	{
		int startLine=0, endLine=-1;
		
		for(int i=0;i<source.length;i++)
			if(source[i].indexOf(functionName) > 0 && source[i].indexOf("void") != -1)
			{
				startLine = i;
				break;
			}
		
		if(startLine > 0)
			endLine = findEndOfFunction(source, startLine);
		
		StringWriter sw = new StringWriter();			//For words
		BufferedWriter bw = new BufferedWriter(sw);
		
		try{
			for(int i=startLine;i<=endLine;i++)				
				if(source[i].indexOf("case") != -1 || source[i].indexOf("default") != -1)
				{
					bw.write(source[i]);
					bw.newLine();
				}
			bw.flush();
		}
		catch(Exception e){
			System.out.println("writing ERROR in SourceRead");
		}		
		
		return sw.toString();		
	}
	
	String extractCaseLine(int startLine)
	{
		int endLine=-1;

		if(startLine > 0)
			endLine = findEndOfFunction(source, startLine);
		
		StringWriter sw = new StringWriter();			//For words
		BufferedWriter bw = new BufferedWriter(sw);
		
		try{
			for(int i=startLine;i<=endLine;i++)				
				if(source[i].indexOf("case") != -1 || source[i].indexOf("default") != -1)
				{
					bw.write(source[i]);
					bw.newLine();
				}
			bw.flush();
		}
		catch(Exception e){
			System.out.println("writing ERROR in SourceRead");
		}		
		
		return sw.toString();		
	}	
	
	String extractCaseLines(String functionName)
	{
		StringWriter sw = new StringWriter();			//For words
		BufferedWriter bw = new BufferedWriter(sw);
		
		try{
			for(int i=0;i<source.length;i++)				
				if(source[i].indexOf(functionName) != -1)
				{
					bw.write(source[i]);
					bw.newLine();					
					bw.write(extractCaseLine(i));
					bw.newLine();
				}
			bw.flush();
		}
		catch(Exception e){
			System.out.println("writing ERROR in SourceRead");
		}		
		
		return sw.toString();		
	}
	
	String extractCalledFunction(String functionName)
	{
		StringWriter sw = new StringWriter();			//For words
		BufferedWriter bw = new BufferedWriter(sw);
		
		try{
			for(int i=0;i<source.length;i++)				
				if(source[i].indexOf(functionName) != -1)
				{
					bw.write(source[i]);
					bw.newLine();
				}
			bw.flush();
		}
		catch(Exception e){
			System.out.println("writing ERROR in SourceRead");
		}		
		
		return sw.toString();
	}
	
	String extractCalledFunctions(String functionNames[])
	{
		String out = "";
		
		for(int i=0;i<functionNames.length;i++)
			out += extractCalledFunction(functionNames[i]);
		
		return out;
	}	
	
	String extractLine(String variable)
	{
		for(int i=0;i<source.length;i++)
			if(source[i].indexOf(variable) != -1 && source[i].indexOf("true") != -1)
				return source[i];

		return "";
	}

	String extractVariable(String variable)
	{
		for(int i=0;i<source.length;i++)
			if(source[i].indexOf(variable) != -1)
				return (source[i]+System.getProperty("line.separator"));
		
		return "";
	}	
	
	String extractVariables(String variables[])
	{
		String out = "";
		
		for(int i=0;i<variables.length;i++)
			out += extractVariable(variables[i]);
		
		return out;
	}
	
	//FocusListener
	public void focusGained(FocusEvent e)
	{
		writeClickLog();
	}
	
	public void focusLost(FocusEvent e)	{}	
	
	//Action listener
	public void actionPerformed(ActionEvent e)
	{
		if(autoSet == true)
			return;
		
		writeButtonLog(e);		
		
//		insideOfActionPerformed(e);
		
		for(int i=1;i<buttonNumber;i++)
			if(e.getSource () == button[i])
			{
				miningOperations(i);
				displayOperations(0);
			}
        
        if(e.getSource () == button[0])
        {
            miningOperations(6);
            displayOperations(0);
        }
		
		if(e.getSource() == miningSelect)
		{
/*			if(autoSet)
			{
				miningSelect.setSelectedIndex(-1);
				autoSet = false;
				return;
			}*/
				
			mining = true;
			selectedMining = miningSelect.getSelectedIndex();
			
			if(selectedMining == -1)
				return;
            
            selectedMining = miningDisplayOrderIndex[selectedMining];
			
			moduleName = moduleNames[selectedMining];
			modulePath = new String(myModulePath);
			modulePath = modulePath.replaceAll(myModuleName,moduleName);
			
			source = fileReadArray(modulePath+moduleName+".java");	
			for(int i=0;i<source.length;i++)
				source[i] = source[i].replaceAll("	","    ");			
			
			autoSet = true;			
			visualizationSelect.setSelectedIndex(-1);
			autoSet = false;	
			
			button[5].setSelected(true);
			miningOperations(0);
			displayOperations(0);
		}
		
		if(e.getSource() == visualizationSelect)
		{
/*			if(autoSet)
			{
				visualizationSelect.setSelectedIndex(-1);
				autoSet = false;
				return;
			}*/
			
			mining = false;			
			selectedVisualization = visualizationSelect.getSelectedIndex();
			
			if(selectedVisualization == -1)
				return;
            
            selectedVisualization = visualizationDisplayOrderIndex[selectedVisualization];
			
			moduleName = visuModuleNames[selectedVisualization];
			modulePath = new String(visuModulePath);
			modulePath = modulePath.replaceAll(visuModuleName,moduleName);			

			source = fileReadArray(modulePath+moduleName+".java");	
			for(int i=0;i<source.length;i++)
				source[i] = source[i].replaceAll("	","    ");		
			
			autoSet = true;			
			miningSelect.setSelectedIndex(-1);
			autoSet = false;	
			
			button[5].setSelected(true);
			miningOperations(0);			
			displayOperations(0);
		}		
	}
}
