Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
V
vdt-plugin
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Commits
Open sidebar
Elphel
vdt-plugin
Commits
bf9e34c8
Commit
bf9e34c8
authored
Mar 01, 2014
by
Andrey Filippov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added commands to remove old state/log files
parent
e24caf8d
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
154 additions
and
12 deletions
+154
-12
ToolLogFile.java
src/com/elphel/vdt/core/launching/ToolLogFile.java
+9
-0
ToolSequence.java
src/com/elphel/vdt/core/tools/params/ToolSequence.java
+68
-5
ClearAction.java
src/com/elphel/vdt/ui/views/ClearAction.java
+1
-1
ClearLogFiles.java
src/com/elphel/vdt/ui/views/ClearLogFiles.java
+39
-2
ClearStateFiles.java
src/com/elphel/vdt/ui/views/ClearStateFiles.java
+37
-4
No files found.
src/com/elphel/vdt/core/launching/ToolLogFile.java
View file @
bf9e34c8
...
@@ -66,6 +66,13 @@ public class ToolLogFile {
...
@@ -66,6 +66,13 @@ public class ToolLogFile {
return
project
.
getFolder
((
logDir
==
null
)?
DEFAULT_LOG_FOLDER:
logDir
);
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
){
public
static
String
getBaseLogName
(
String
logTool
,
String
logName
){
String
baseName
=
logTool
;
String
baseName
=
logTool
;
if
((
logName
!=
null
)
&&
(
logName
.
length
()>
0
))
baseName
+=
TOOL_TO_LINE_SEPARATOR
+
logName
;
if
((
logName
!=
null
)
&&
(
logName
.
length
()>
0
))
baseName
+=
TOOL_TO_LINE_SEPARATOR
+
logName
;
...
@@ -78,6 +85,8 @@ public class ToolLogFile {
...
@@ -78,6 +85,8 @@ public class ToolLogFile {
return
logTool
+
REGEX_SEP_TO_END
;
return
logTool
+
REGEX_SEP_TO_END
;
}
}
public
static
String
getTimeStamp
(
String
logTool
,
String
name
){
public
static
String
getTimeStamp
(
String
logTool
,
String
name
){
if
(
name
==
null
)
return
null
;
if
(
name
==
null
)
return
null
;
// remove prefix
// remove prefix
...
...
src/com/elphel/vdt/core/tools/params/ToolSequence.java
View file @
bf9e34c8
...
@@ -102,14 +102,77 @@ public class ToolSequence {
...
@@ -102,14 +102,77 @@ public class ToolSequence {
}
}
toolFinished
(
null
);
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
public
void
clearLogFiles
(){
Set
<
String
>
linkFilesTargets
=
new
HashSet
<
String
>();
MessageUI
.
error
(
"TODO: implement clearLogFiles()"
);
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
;
}
}
}
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
){
public
void
setUnfinishedBoot
(
IMemento
memento
){
unfinishedMemento
=
memento
;
unfinishedMemento
=
memento
;
if
(
memento
!=
null
){
if
(
memento
!=
null
){
...
...
src/com/elphel/vdt/ui/views/ClearAction.java
View file @
bf9e34c8
...
@@ -28,7 +28,7 @@ abstract public class ClearAction extends Action {
...
@@ -28,7 +28,7 @@ abstract public class ClearAction extends Action {
private
String
message
;
private
String
message
;
pr
ivate
static
final
String
[]
buttonText
=
new
String
[]{
"Delete"
,
"Cancel"
};
pr
otected
static
final
String
[]
buttonText
=
new
String
[]{
"Delete"
,
"Cancel"
};
public
ClearAction
(
String
message
)
{
public
ClearAction
(
String
message
)
{
this
.
message
=
message
;
this
.
message
=
message
;
...
...
src/com/elphel/vdt/ui/views/ClearLogFiles.java
View file @
bf9e34c8
...
@@ -16,7 +16,13 @@
...
@@ -16,7 +16,13 @@
*******************************************************************************/
*******************************************************************************/
package
com
.
elphel
.
vdt
.
ui
.
views
;
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.core.tools.params.ToolSequence
;
import
com.elphel.vdt.veditor.VerilogPlugin
;
public
class
ClearLogFiles
extends
ClearAction
{
public
class
ClearLogFiles
extends
ClearAction
{
private
ToolSequence
toolSequence
;
private
ToolSequence
toolSequence
;
...
@@ -26,9 +32,40 @@ public class ClearLogFiles extends ClearAction {
...
@@ -26,9 +32,40 @@ public class ClearLogFiles extends ClearAction {
this
.
toolSequence
=
toolSequence
;
this
.
toolSequence
=
toolSequence
;
}
}
// public void clear() {
// toolSequence.clearLogFiles();
// }
public
void
clear
()
{
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
}
// class ContextsAction
src/com/elphel/vdt/ui/views/ClearStateFiles.java
View file @
bf9e34c8
...
@@ -16,19 +16,52 @@
...
@@ -16,19 +16,52 @@
*******************************************************************************/
*******************************************************************************/
package
com
.
elphel
.
vdt
.
ui
.
views
;
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.core.tools.params.ToolSequence
;
import
com.elphel.vdt.veditor.VerilogPlugin
;
public
class
ClearStateFiles
extends
ClearAction
{
public
class
ClearStateFiles
extends
ClearAction
{
private
ToolSequence
toolSequence
;
private
ToolSequence
toolSequence
;
public
ClearStateFiles
(
String
message
,
ToolSequence
toolSequence
)
{
public
ClearStateFiles
(
String
message
,
ToolSequence
toolSequence
)
{
super
(
message
);
super
(
message
);
this
.
toolSequence
=
toolSequence
;
this
.
toolSequence
=
toolSequence
;
}
}
public
void
clear
()
{
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
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment