Commit 4ab58c67 authored by Andrey Filippov's avatar Andrey Filippov
Browse files

Started adding ISE tools, fixed persistent storage when switching

projects
parent 07d87ca2
Loading
Loading
Loading
Loading
+24 −10
Original line number Original line Diff line number Diff line
@@ -18,11 +18,7 @@
package com.elphel.vdt;
package com.elphel.vdt;


import java.util.ArrayList;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.List;
import java.util.Iterator;
import java.util.Set;
import java.util.Vector;


import com.elphel.vdt.ui.variables.SelectedResourceManager;
import com.elphel.vdt.ui.variables.SelectedResourceManager;
import com.elphel.vdt.veditor.VerilogPlugin;
import com.elphel.vdt.veditor.VerilogPlugin;
@@ -41,9 +37,6 @@ import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.QualifiedName;
import org.eclipse.jface.viewers.Viewer;
import org.eclipse.jface.viewers.ViewerFilter;


/**
/**
 * Verilog file utilities.
 * Verilog file utilities.
@@ -52,6 +45,14 @@ import org.eclipse.jface.viewers.ViewerFilter;
 * @author  Lvov Konstantin
 * @author  Lvov Konstantin
 */
 */
public class VerilogUtils {
public class VerilogUtils {
	public static boolean  existsVeditorOutlineDatabase(IProject project){
		try {
			if (project.getSessionProperty(VerilogPlugin.getOutlineDatabaseId()) !=null) return true;
		} catch (CoreException e) {
			System.out.println("Probably project is closed: "+e);
		}
		return false;
	}
	
	
	public static OutlineDatabase getVeditorOutlineDatabase(IProject project){
	public static OutlineDatabase getVeditorOutlineDatabase(IProject project){
		OutlineDatabase database=null;
		OutlineDatabase database=null;
@@ -59,17 +60,30 @@ public class VerilogUtils {
		try {
		try {
			database = (OutlineDatabase)project.getSessionProperty(VerilogPlugin.getOutlineDatabaseId());			
			database = (OutlineDatabase)project.getSessionProperty(VerilogPlugin.getOutlineDatabaseId());			
		} catch (CoreException e) {
		} catch (CoreException e) {
			e.printStackTrace();
			System.out.println("Probably project is closed: "+e);
		}
		}
		if (database !=null) return database;
		if (database !=null) return database;
   		if (VerilogPlugin.getPreferenceBoolean(PreferenceStrings.DEBUG_OTHER))
   			System.out.println("database is null, looking for the HdlDocument");
   			System.out.println("database is null, looking for the HdlDocument");
		try {
		try {
			hdlDocument=(HdlDocument)project.getSessionProperty(VerilogPlugin.getHdlDocumentId());
			hdlDocument=(HdlDocument)project.getSessionProperty(VerilogPlugin.getHdlDocumentId());
			if ((hdlDocument!=null) && (hdlDocument.getFile()!=null)) {
				if (VerilogPlugin.getPreferenceBoolean(PreferenceStrings.DEBUG_OTHER))
					System.out.println("database is null, looking for the HdlDocument="+hdlDocument.getFile().toString());
			} else {
				if (VerilogPlugin.getPreferenceBoolean(PreferenceStrings.DEBUG_OTHER))
					System.out.println("database is null, HdlDocument="+((hdlDocument==null)?"NULL":" not null, but getFile() is NULL"));
			}
			
		} catch (CoreException e) {			
		} catch (CoreException e) {			
			e.printStackTrace();
			e.printStackTrace();
		}
		}
		if (hdlDocument!=null) return hdlDocument.getOutlineDatabase(); /* will create a new one if does not exist */
		if (hdlDocument!=null) return hdlDocument.getOutlineDatabase(); /* will create a new one if does not exist */
		// Create HdlDocument from selected/restored HDLfile
		// Create HdlDocument from selected/restored HDLfile
		if (SelectedResourceManager.getDefault().getChosenVerilogFile()==null) {
			System.out.println("database is null, and no Verilog file is selected to create one.");
			return null;
		}
		hdlDocument=new VerilogDocument(project, (IFile) SelectedResourceManager.getDefault().getChosenVerilogFile());
		hdlDocument=new VerilogDocument(project, (IFile) SelectedResourceManager.getDefault().getChosenVerilogFile());
		return hdlDocument.getOutlineDatabase(); /* will create a new one if does not exist */
		return hdlDocument.getOutlineDatabase(); /* will create a new one if does not exist */
	}
	}
+19 −2
Original line number Original line Diff line number Diff line
@@ -22,8 +22,11 @@ import java.util.ArrayList;
import java.util.List;
import java.util.List;





import org.eclipse.core.resources.IProject;
import org.eclipse.ui.IMemento;
import org.eclipse.ui.IMemento;



//import com.elphel.vdt.VDTPlugin;
//import com.elphel.vdt.VDTPlugin;
import com.elphel.vdt.veditor.VerilogPlugin;
import com.elphel.vdt.veditor.VerilogPlugin;
import com.elphel.vdt.core.options.OptionsCore;
import com.elphel.vdt.core.options.OptionsCore;
@@ -78,15 +81,29 @@ public class ToolsCore {
    }
    }
    
    
    public static void saveToolsState(IMemento memento){
    public static void saveToolsState(IMemento memento){
    	if (getConfig().getContextManager().getToolList()!=null) {
    		for (Tool tool : getConfig().getContextManager().getToolList())
    		for (Tool tool : getConfig().getContextManager().getToolList())
    			tool.saveState(memento);
    			tool.saveState(memento);
    	}
    	}
    }
    
    
    public static void restoreToolsState(IMemento memento){
    public static void restoreToolsState(IMemento memento){
        for (Tool tool : getConfig().getContextManager().getToolList())
        for (Tool tool : getConfig().getContextManager().getToolList())
        	tool.restoreState(memento);
        	tool.restoreState(memento);
    }
    }


    public static void saveToolsState(IProject project){
    	if (getConfig().getContextManager().getToolList()!=null) {
    		for (Tool tool : getConfig().getContextManager().getToolList())
    			tool.saveState(project);
    	}
    }
    
    public static void restoreToolsState(IProject project){
        for (Tool tool : getConfig().getContextManager().getToolList())
        	tool.restoreState(project);
    }



    public static Tool getToolWorkingCopy(String toolID) {
    public static Tool getToolWorkingCopy(String toolID) {
        Tool tool = getTool(toolID);
        Tool tool = getTool(toolID);
+3 −1
Original line number Original line Diff line number Diff line
@@ -108,7 +108,9 @@ public class FilteredSourceListGenerator extends AbstractGenerator {
            }
            }
            file_names=fileList.toArray(new String[0]);
            file_names=fileList.toArray(new String[0]);
        } else {
        } else {
            fault("There is no selected project");
//            fault("There is no selected project");
            System.out.println(getName()+": no project selected");
            return new String[] {""};
        }
        }
        return file_names;
        return file_names;
    }
    }
+4 −1
Original line number Original line Diff line number Diff line
@@ -49,7 +49,10 @@ public class ProjectNameGenerator extends AbstractGenerator {
            String project_name = resource.getProject().getName(); 
            String project_name = resource.getProject().getName(); 
            value = new String[]{project_name};
            value = new String[]{project_name};
        } else {
        } else {
            fault("There is no selected project");
//            fault("There is no selected project");
            System.out.println(getName()+": no project selected");
            return new String[] {""};
            
        }
        }
        return value;
        return value;
    }
    }
+3 −1
Original line number Original line Diff line number Diff line
@@ -51,7 +51,9 @@ public class ProjectPathGenerator extends AbstractGenerator {
            String project_name = workspaceRoot+resource.getProject().getFullPath().toString()+File.separator; 
            String project_name = workspaceRoot+resource.getProject().getFullPath().toString()+File.separator; 
            value = new String[]{project_name};
            value = new String[]{project_name};
        } else {
        } else {
            fault("There is no selected project");
//            fault("There is no selected project");
            System.out.println(getName()+": no project selected");
            return new String[] {""};
        }
        }
        return value;
        return value;
    }
    }
Loading