Loading src/com/elphel/vdt/core/launching/ToolLogFile.java +9 −0 Original line number Diff line number Diff line Loading @@ -66,6 +66,13 @@ public class ToolLogFile { return project.getFolder((logDir==null)?DEFAULT_LOG_FOLDER:logDir); } public static String getLinkOutName(String logTool, String logName){ return getBaseLogName(logTool, logName)+OUTPUT_LOG_SUFFIX+"."+LOG_EXTENSION; } public static String getLinkErrName(String logTool, String logName){ return getBaseLogName(logTool, logName)+ERROR_LOG_SUFFIX+"."+LOG_EXTENSION; } public static String getBaseLogName(String logTool, String logName){ String baseName=logTool; if ((logName!=null) && (logName.length()>0))baseName+=TOOL_TO_LINE_SEPARATOR+logName; Loading @@ -78,6 +85,8 @@ public class ToolLogFile { return logTool+REGEX_SEP_TO_END; } public static String getTimeStamp(String logTool, String name){ if (name==null) return null; // remove prefix Loading src/com/elphel/vdt/core/tools/params/ToolSequence.java +68 −5 Original line number Diff line number Diff line Loading @@ -102,12 +102,75 @@ public class ToolSequence { } toolFinished(null); } public void clearStateFiles(){ MessageUI.error("TODO: implement clearStateFiles()"); public Set<IFile> getOldFiles(Set<String> dirs){ IProject project = SelectedResourceManager.getDefault().getSelectedProject(); // should not be null when we got here Set<String> linkFilesTargets=new HashSet<String>(); Set<IFile> nonLinkFiles=new HashSet<IFile>(); for (String dir:dirs){ IFolder stateDir= project.getFolder(dir); if (stateDir.exists()){ IResource [] files; try { files=stateDir.members(); } catch (CoreException e) { System.out.println("Error getting member resources in directory "+stateDir.getLocation().toOSString()); continue; } for (IResource file:files){ if (file.getType()==IResource.FILE) { if (file.isLinked()){ // System.out.println("Got linked file: "+file.getLocation().toOSString()); linkFilesTargets.add(file.getRawLocation().toString()); } else { // System.out.println("Got non=link file: "+file.getLocation().toOSString()); nonLinkFiles.add((IFile) file); } } } } } DEBUG_PRINT("Got "+linkFilesTargets.size()+" links, "+nonLinkFiles.size()+" regular files"); Set<IFile> fileToRemove=new HashSet<IFile>(nonLinkFiles); for (IFile file:nonLinkFiles){ String fileString=file.getLocation().toString(); for (String linkTarget:linkFilesTargets){ if (linkTarget.equals(fileString)){ fileToRemove.remove(file); break; } } public void clearLogFiles(){ MessageUI.error("TODO: implement clearLogFiles()"); } DEBUG_PRINT("Left "+fileToRemove.size()+" to remove:"); for (IFile file:fileToRemove){ DEBUG_PRINT("---- "+file.getLocation().toOSString()); } return fileToRemove; } public Set<String> getStateDirs(){ Set <String> dirs = new HashSet<String>(); for (Tool tool : ToolsCore.getConfig().getContextManager().getToolList()){ String dir=tool.getStateDir(); if (dir!=null){ dirs.add(dir); } } return dirs; } public Set<String> getLogDirs(){ Set <String> dirs = new HashSet<String>(); for (Tool tool : ToolsCore.getConfig().getContextManager().getToolList()){ String dir=tool.getLogDir(); if (dir!=null){ dirs.add(dir); } } return dirs; } public void setUnfinishedBoot(IMemento memento){ Loading src/com/elphel/vdt/ui/views/ClearAction.java +1 −1 Original line number Diff line number Diff line Loading @@ -28,7 +28,7 @@ abstract public class ClearAction extends Action { private String message; private static final String[] buttonText = new String[]{"Delete", "Cancel"}; protected static final String[] buttonText = new String[]{"Delete", "Cancel"}; public ClearAction(String message) { this.message = message; Loading src/com/elphel/vdt/ui/views/ClearLogFiles.java +39 −2 Original line number Diff line number Diff line Loading @@ -16,7 +16,13 @@ *******************************************************************************/ package com.elphel.vdt.ui.views; import java.util.Set; import org.eclipse.core.resources.IFile; import org.eclipse.core.runtime.CoreException; import org.eclipse.jface.dialogs.MessageDialog; import org.eclipse.swt.widgets.Shell; import com.elphel.vdt.core.tools.params.ToolSequence; import com.elphel.vdt.veditor.VerilogPlugin; public class ClearLogFiles extends ClearAction { private ToolSequence toolSequence; Loading @@ -26,9 +32,40 @@ public class ClearLogFiles extends ClearAction { this. toolSequence= toolSequence; } // public void clear() { // toolSequence.clearLogFiles(); // } public void clear() { toolSequence.clearLogFiles(); String msg="The following files will be deleted:\n\n"; Set<IFile> toRemove=toolSequence.getOldFiles(toolSequence.getLogDirs()); int index=0; for (IFile file:toRemove){ index++; // msg+=file.getLocation().toOSString()+"\n"; msg+=file.getName()+"\n"; if (index>25){ msg+="\n... and more"; break; } } if (toRemove.size()==0){ msg="There are no files to be deleted"; } Shell shell = VerilogPlugin.getActiveWorkbenchShell(); MessageDialog messageBox = new MessageDialog( shell, "Warning", null , msg , MessageDialog.QUESTION , buttonText, 1); messageBox.open(); if (messageBox.getReturnCode() == 0) { for (IFile file:toRemove){ try { file.delete(0,null); } catch (CoreException e) { System.out.println("Could not delete "+file.getLocation().toOSString()); } } } } } // class ContextsAction src/com/elphel/vdt/ui/views/ClearStateFiles.java +37 −4 Original line number Diff line number Diff line Loading @@ -16,7 +16,13 @@ *******************************************************************************/ package com.elphel.vdt.ui.views; import java.util.Set; import org.eclipse.core.resources.IFile; import org.eclipse.core.runtime.CoreException; import org.eclipse.jface.dialogs.MessageDialog; import org.eclipse.swt.widgets.Shell; import com.elphel.vdt.core.tools.params.ToolSequence; import com.elphel.vdt.veditor.VerilogPlugin; public class ClearStateFiles extends ClearAction { private ToolSequence toolSequence; Loading @@ -27,8 +33,35 @@ public class ClearStateFiles extends ClearAction { } public void clear() { toolSequence.clearStateFiles(); String msg="The following files will be deleted:\n\n"; Set<IFile> toRemove=toolSequence.getOldFiles(toolSequence.getStateDirs()); int index=0; for (IFile file:toRemove){ index++; msg+=file.getName()+"\n"; if (index>25){ msg+="\n... and more"; break; } } if (toRemove.size()==0){ msg="There are no files to be deleted"; } Shell shell = VerilogPlugin.getActiveWorkbenchShell(); MessageDialog messageBox = new MessageDialog( shell, "Warning", null , msg , MessageDialog.QUESTION , buttonText, 1); messageBox.open(); if (messageBox.getReturnCode() == 0) { for (IFile file:toRemove){ try { file.delete(0,null); } catch (CoreException e) { System.out.println("Could not delete "+file.getLocation().toOSString()); } } } } } // class ContextsAction } Loading
src/com/elphel/vdt/core/launching/ToolLogFile.java +9 −0 Original line number Diff line number Diff line Loading @@ -66,6 +66,13 @@ public class ToolLogFile { return project.getFolder((logDir==null)?DEFAULT_LOG_FOLDER:logDir); } public static String getLinkOutName(String logTool, String logName){ return getBaseLogName(logTool, logName)+OUTPUT_LOG_SUFFIX+"."+LOG_EXTENSION; } public static String getLinkErrName(String logTool, String logName){ return getBaseLogName(logTool, logName)+ERROR_LOG_SUFFIX+"."+LOG_EXTENSION; } public static String getBaseLogName(String logTool, String logName){ String baseName=logTool; if ((logName!=null) && (logName.length()>0))baseName+=TOOL_TO_LINE_SEPARATOR+logName; Loading @@ -78,6 +85,8 @@ public class ToolLogFile { return logTool+REGEX_SEP_TO_END; } public static String getTimeStamp(String logTool, String name){ if (name==null) return null; // remove prefix Loading
src/com/elphel/vdt/core/tools/params/ToolSequence.java +68 −5 Original line number Diff line number Diff line Loading @@ -102,12 +102,75 @@ public class ToolSequence { } toolFinished(null); } public void clearStateFiles(){ MessageUI.error("TODO: implement clearStateFiles()"); public Set<IFile> getOldFiles(Set<String> dirs){ IProject project = SelectedResourceManager.getDefault().getSelectedProject(); // should not be null when we got here Set<String> linkFilesTargets=new HashSet<String>(); Set<IFile> nonLinkFiles=new HashSet<IFile>(); for (String dir:dirs){ IFolder stateDir= project.getFolder(dir); if (stateDir.exists()){ IResource [] files; try { files=stateDir.members(); } catch (CoreException e) { System.out.println("Error getting member resources in directory "+stateDir.getLocation().toOSString()); continue; } for (IResource file:files){ if (file.getType()==IResource.FILE) { if (file.isLinked()){ // System.out.println("Got linked file: "+file.getLocation().toOSString()); linkFilesTargets.add(file.getRawLocation().toString()); } else { // System.out.println("Got non=link file: "+file.getLocation().toOSString()); nonLinkFiles.add((IFile) file); } } } } } DEBUG_PRINT("Got "+linkFilesTargets.size()+" links, "+nonLinkFiles.size()+" regular files"); Set<IFile> fileToRemove=new HashSet<IFile>(nonLinkFiles); for (IFile file:nonLinkFiles){ String fileString=file.getLocation().toString(); for (String linkTarget:linkFilesTargets){ if (linkTarget.equals(fileString)){ fileToRemove.remove(file); break; } } public void clearLogFiles(){ MessageUI.error("TODO: implement clearLogFiles()"); } DEBUG_PRINT("Left "+fileToRemove.size()+" to remove:"); for (IFile file:fileToRemove){ DEBUG_PRINT("---- "+file.getLocation().toOSString()); } return fileToRemove; } public Set<String> getStateDirs(){ Set <String> dirs = new HashSet<String>(); for (Tool tool : ToolsCore.getConfig().getContextManager().getToolList()){ String dir=tool.getStateDir(); if (dir!=null){ dirs.add(dir); } } return dirs; } public Set<String> getLogDirs(){ Set <String> dirs = new HashSet<String>(); for (Tool tool : ToolsCore.getConfig().getContextManager().getToolList()){ String dir=tool.getLogDir(); if (dir!=null){ dirs.add(dir); } } return dirs; } public void setUnfinishedBoot(IMemento memento){ Loading
src/com/elphel/vdt/ui/views/ClearAction.java +1 −1 Original line number Diff line number Diff line Loading @@ -28,7 +28,7 @@ abstract public class ClearAction extends Action { private String message; private static final String[] buttonText = new String[]{"Delete", "Cancel"}; protected static final String[] buttonText = new String[]{"Delete", "Cancel"}; public ClearAction(String message) { this.message = message; Loading
src/com/elphel/vdt/ui/views/ClearLogFiles.java +39 −2 Original line number Diff line number Diff line Loading @@ -16,7 +16,13 @@ *******************************************************************************/ package com.elphel.vdt.ui.views; import java.util.Set; import org.eclipse.core.resources.IFile; import org.eclipse.core.runtime.CoreException; import org.eclipse.jface.dialogs.MessageDialog; import org.eclipse.swt.widgets.Shell; import com.elphel.vdt.core.tools.params.ToolSequence; import com.elphel.vdt.veditor.VerilogPlugin; public class ClearLogFiles extends ClearAction { private ToolSequence toolSequence; Loading @@ -26,9 +32,40 @@ public class ClearLogFiles extends ClearAction { this. toolSequence= toolSequence; } // public void clear() { // toolSequence.clearLogFiles(); // } public void clear() { toolSequence.clearLogFiles(); String msg="The following files will be deleted:\n\n"; Set<IFile> toRemove=toolSequence.getOldFiles(toolSequence.getLogDirs()); int index=0; for (IFile file:toRemove){ index++; // msg+=file.getLocation().toOSString()+"\n"; msg+=file.getName()+"\n"; if (index>25){ msg+="\n... and more"; break; } } if (toRemove.size()==0){ msg="There are no files to be deleted"; } Shell shell = VerilogPlugin.getActiveWorkbenchShell(); MessageDialog messageBox = new MessageDialog( shell, "Warning", null , msg , MessageDialog.QUESTION , buttonText, 1); messageBox.open(); if (messageBox.getReturnCode() == 0) { for (IFile file:toRemove){ try { file.delete(0,null); } catch (CoreException e) { System.out.println("Could not delete "+file.getLocation().toOSString()); } } } } } // class ContextsAction
src/com/elphel/vdt/ui/views/ClearStateFiles.java +37 −4 Original line number Diff line number Diff line Loading @@ -16,7 +16,13 @@ *******************************************************************************/ package com.elphel.vdt.ui.views; import java.util.Set; import org.eclipse.core.resources.IFile; import org.eclipse.core.runtime.CoreException; import org.eclipse.jface.dialogs.MessageDialog; import org.eclipse.swt.widgets.Shell; import com.elphel.vdt.core.tools.params.ToolSequence; import com.elphel.vdt.veditor.VerilogPlugin; public class ClearStateFiles extends ClearAction { private ToolSequence toolSequence; Loading @@ -27,8 +33,35 @@ public class ClearStateFiles extends ClearAction { } public void clear() { toolSequence.clearStateFiles(); String msg="The following files will be deleted:\n\n"; Set<IFile> toRemove=toolSequence.getOldFiles(toolSequence.getStateDirs()); int index=0; for (IFile file:toRemove){ index++; msg+=file.getName()+"\n"; if (index>25){ msg+="\n... and more"; break; } } if (toRemove.size()==0){ msg="There are no files to be deleted"; } Shell shell = VerilogPlugin.getActiveWorkbenchShell(); MessageDialog messageBox = new MessageDialog( shell, "Warning", null , msg , MessageDialog.QUESTION , buttonText, 1); messageBox.open(); if (messageBox.getReturnCode() == 0) { for (IFile file:toRemove){ try { file.delete(0,null); } catch (CoreException e) { System.out.println("Could not delete "+file.getLocation().toOSString()); } } } } } // class ContextsAction }