Skip to content

Commit 46efcde

Browse files
committed
fix: version, last status with statistics
1 parent 6b6565e commit 46efcde

File tree

6 files changed

+89
-47
lines changed

6 files changed

+89
-47
lines changed

pom.xml

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414

1515
<groupId>com.berdal84</groupId>
1616
<artifactId>Mageek</artifactId>
17-
<version>1</version>
17+
<version>1.1.1</version>
1818

1919
<name>Mageek</name>
2020
<description>A small plugin to colorize images channels, works with multi series/channels/slices.</description>
@@ -143,4 +143,19 @@
143143
<artifactId>bio-formats_plugins</artifactId>
144144
</dependency>
145145
</dependencies>
146+
147+
<build>
148+
<resources>
149+
<resource>
150+
<directory>src/main/resources</directory>
151+
<filtering>true</filtering>
152+
</resource>
153+
154+
<resource>
155+
<directory>src/main/resources</directory>
156+
<filtering>false</filtering>
157+
</resource>
158+
</resources>
159+
</build>
160+
146161
</project>

src/main/java/com/berdal84/mageek/FileHelper.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ public static ArrayList<String> getFileExtensions(ArrayList<File> _files)
7272
* @param _recursively
7373
* @return
7474
*/
75-
public static ArrayList<File> getFiles(File _directory, boolean _recursively)
75+
public static ArrayList<File> getFiles(File _directory, boolean _recursively, String _ignoreFolderName)
7676
{
7777
ArrayList<File> result = new ArrayList<>();
7878
File[] content = _directory.listFiles();
@@ -81,11 +81,11 @@ public static ArrayList<File> getFiles(File _directory, boolean _recursively)
8181
{
8282
for (File file : content)
8383
{
84-
if (file.isDirectory())
84+
if (file.isDirectory() && !file.getName().equals(_ignoreFolderName) )
8585
{
8686
if (_recursively)
8787
{
88-
ArrayList<File> subFolderFiles = getFiles(file, true);
88+
ArrayList<File> subFolderFiles = getFiles(file, true, _ignoreFolderName);
8989
result.addAll(subFolderFiles);
9090
}
9191
}
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
/*
2+
* The MIT License
3+
*
4+
* Copyright 2022 Berdal84.
5+
*
6+
* Permission is hereby granted, free of charge, to any person obtaining a copy
7+
* of this software and associated documentation files (the "Software"), to deal
8+
* in the Software without restriction, including without limitation the rights
9+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10+
* copies of the Software, and to permit persons to whom the Software is
11+
* furnished to do so, subject to the following conditions:
12+
*
13+
* The above copyright notice and this permission notice shall be included in
14+
* all copies or substantial portions of the Software.
15+
*
16+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22+
* THE SOFTWARE.
23+
*/
24+
package com.berdal84.mageek;
25+
26+
import java.io.BufferedReader;
27+
import java.io.IOException;
28+
import java.io.InputStream;
29+
import java.io.InputStreamReader;
30+
import java.util.Optional;
31+
32+
public class PackageHelper
33+
{
34+
// Reads the version from the version.txt file, where maven writes the value when compiling
35+
public static String getVersion()
36+
{
37+
try
38+
{
39+
InputStream inputStream = PackageHelper.class.getClassLoader().getResourceAsStream("version.txt");
40+
InputStreamReader inputStreamReader = new InputStreamReader(Optional.ofNullable(inputStream).orElseThrow(IOException::new));
41+
try ( BufferedReader reader = new BufferedReader(inputStreamReader))
42+
{
43+
return reader.readLine();
44+
}
45+
finally
46+
{
47+
inputStream.close();
48+
inputStreamReader.close();
49+
}
50+
}
51+
catch (IOException e)
52+
{
53+
System.out.printf("Can't get version", e);
54+
}
55+
return "Unknown";
56+
}
57+
}

src/main/java/com/berdal84/mageek/Plugin.java

Lines changed: 2 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,11 @@
1414
import io.scif.services.DatasetIOService;
1515

1616
import net.imagej.DatasetService;
17-
import net.imagej.ImageJ;
1817

1918
import net.imglib2.type.numeric.RealType;
2019

2120
import org.scijava.command.Command;
2221
import org.scijava.plugin.Parameter;
23-
import org.scijava.run.RunService;
2422
import org.scijava.ui.DialogPrompt.MessageType;
2523
import org.scijava.ui.DialogPrompt.OptionType;
2624
import org.scijava.ui.DialogPrompt;
@@ -86,9 +84,6 @@ public class Plugin<T extends RealType<T>> implements Command
8684
/* The script title */
8785
private final String title;
8886

89-
/* The script title */
90-
private final String version;
91-
9287
/* Scanned extensions */
9388
private ArrayList<String> scannedFileExtensions;
9489

@@ -128,7 +123,6 @@ public Plugin()
128123
{
129124
currentProcessThread = null;
130125
title = "Mageek";
131-
version = "1.0.0";
132126
batchMode = true;
133127
analysedFolderName = "ANALYSED";
134128
scannedFileExtensions = new ArrayList<>();
@@ -182,7 +176,7 @@ public void run()
182176
);
183177
gui.setSourceDirectory(sourceFolder.toString());
184178

185-
scannedFiles = FileHelper.getFiles(sourceFolder, true);
179+
scannedFiles = FileHelper.getFiles(sourceFolder, true, analysedFolderName);
186180
gui.setFileList(scannedFiles);
187181
scannedFileExtensions = FileHelper.getFileExtensions(scannedFiles);
188182
gui.setFileExtensionList(scannedFileExtensions);
@@ -340,7 +334,7 @@ public void windowDeactivated(WindowEvent e)
340334
}
341335
});
342336

343-
gui.setStatus(String.format("Welcome to %s v%s", title, version));
337+
gui.setStatus(String.format("Welcome to %s v%s", title, PackageHelper.getVersion() ));
344338
gui.setSourceDirectory("Select a source directory ...");
345339

346340
gui.setAvailableColors(MetaColor.All);
@@ -507,39 +501,6 @@ private boolean createOutputDirectory()
507501
}
508502
return success;
509503
}
510-
511-
/**
512-
* Update the statistics in status bar
513-
*/
514-
void displayStatisticsInStatusBar()
515-
{
516-
String innerMessage;
517-
518-
MessageType messageType;
519-
520-
if (this.sourceFolder == null)
521-
{
522-
innerMessage = "Nothing to process ...";
523-
messageType = MessageType.INFORMATION_MESSAGE;
524-
}
525-
else
526-
{
527-
innerMessage = String.format(
528-
"Process done, %d file(s) processed (%d ignored)",
529-
processedFiles.size(),
530-
ignoredFiles.size()
531-
);
532-
533-
messageType = MessageType.INFORMATION_MESSAGE;
534-
}
535-
536-
String message = String.format(
537-
"%s --- Hasta la vista, baby. ^^",
538-
innerMessage
539-
);
540-
541-
gui.setStatus(message);
542-
}
543504

544505
private ImagePlus[] open(File file) throws IOException, FormatException
545506
{

src/main/java/com/berdal84/mageek/Process.java

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -243,8 +243,14 @@ public void run()
243243

244244
setProgress( (int)(((float)processedFiles.size() / (float)files.size()) * 100.f) );
245245
}
246-
247-
setStatus("Processing DONE");
246+
247+
String message = String.format(
248+
"Process done, %d file(s) processed (%d ignored)"
249+
+ " --- Hasta la vista, baby. ^^",
250+
processedFiles.size(),
251+
ignoredFiles.size()
252+
);
253+
setStatus(message);
248254
}
249255

250256
/**
@@ -299,4 +305,5 @@ public void setListener(Listener _listener)
299305
{
300306
listener = _listener;
301307
}
308+
302309
}

src/main/resources/version.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
${project.version}
2+
// do not modify the first line

0 commit comments

Comments
 (0)