Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
Dutchman101 committed Mar 13, 2018
0 parents commit 7d91aff
Show file tree
Hide file tree
Showing 16 changed files with 1,110 additions and 0 deletions.
22 changes: 22 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# Compiled class file
*.class

# Log file
*.log

# BlueJ files
*.ctxt

# Mobile Tools for Java (J2ME)
.mtj.tmp/

# Package Files #
*.jar
*.war
*.ear
*.zip
*.tar.gz
*.rar

# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml
hs_err_pid*
32 changes: 32 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# Trailing space trimmer

This JAVA application allows you to trim trailing spaces and empty tabs over a whole project.
It's able to get rid of all trailing spaces for all code files in a directory and its subdirectories, so you could work on a whole repository at once.

All programming languages are supported, you can input a comma-separated list of code-file extensions into the app's GUI, so that all matching files are included in the operation.

Definition of GUI option 1 ("Remove trailing spaces/tabs"):
- empty whitespaces at the end of a line consisting of characters (only the very end of it, no loss of indent)
- actual tabs/spaces content in empty lines (it won't delete the empty lines itself, only bring it back to 0 bytes)

[Example] See below image for the effects of this option:

[img] https://i.imgur.com/i35spWx.png

Definition of GUI option 2 ("Remove empty lines"):
- delete empty lines by completely removing them. This will most often be separator lines between blocks of code, added by the developer's preference over the lifespan of a project.

[Example] See below image for the effects of this option:

[img] https://i.imgur.com/KGGnhz8.png


The stable, multi-threaded approach and progress bar, should allow you to work on an high amount of files simultaneously and large repositories.

This is freeware and free to use, distribute, compilate and modify on private and corporate level. No further updates will be commited by myself, although you're free to submit Pull requests.

GUI interface:

https://i.imgur.com/N5dEWo3.png

Processing the 1100 files in above example GUI image, costed just under 3 seconds.
11 changes: 11 additions & 0 deletions SpaceTrimmer.iml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<?xml version="1.0" encoding="UTF-8"?>
<module type="JAVA_MODULE" version="4">
<component name="NewModuleRootManager" inherit-compiler-output="true">
<exclude-output />
<content url="file://$MODULE_DIR$">
<sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" />
</content>
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
</component>
</module>
3 changes: 3 additions & 0 deletions src/META-INF/MANIFEST.MF
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
Manifest-Version: 1.0
Main-Class: nl.dutchman.spacetrimmer.launcher.Launcher

19 changes: 19 additions & 0 deletions src/nl/dutchman/spacetrimmer/launcher/Launcher.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
package nl.dutchman.spacetrimmer.launcher;

import nl.dutchman.spacetrimmer.ui.WindowController;

public class Launcher
{
public static void main(String[] args)
{
try
{
WindowController windowController = new WindowController();
windowController.display();
}
catch (Exception e)
{
e.printStackTrace();
}
}
}
18 changes: 18 additions & 0 deletions src/nl/dutchman/spacetrimmer/model/ProcessableFile.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package nl.dutchman.spacetrimmer.model;

import java.io.File;

public class ProcessableFile
{
private File file;
private long fileSize;

public ProcessableFile(File file, long fileSize)
{
this.file = file;
this.fileSize = fileSize;
}

public File getFile() { return file; }
public long getFileSize() { return fileSize; }
}
Binary file added src/nl/dutchman/spacetrimmer/resources/icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/nl/dutchman/spacetrimmer/resources/ready.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
229 changes: 229 additions & 0 deletions src/nl/dutchman/spacetrimmer/ui/MainWindow.form
Original file line number Diff line number Diff line change
@@ -0,0 +1,229 @@
<?xml version="1.0" encoding="UTF-8"?>
<form xmlns="http://www.intellij.com/uidesigner/form/" version="1" bind-to-class="nl.dutchman.spacetrimmer.ui.MainWindow">
<grid id="27dc6" binding="contentPane" layout-manager="GridLayoutManager" row-count="2" column-count="1" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
<margin top="10" left="20" bottom="10" right="20"/>
<constraints>
<xy x="20" y="20" width="800" height="600"/>
</constraints>
<properties>
<maximumSize width="800" height="600"/>
<minimumSize width="800" height="600"/>
<preferredSize width="800" height="600"/>
</properties>
<border type="none"/>
<children>
<grid id="b7c28" binding="consoleContainer" layout-manager="GridLayoutManager" row-count="1" column-count="1" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
<margin top="0" left="0" bottom="0" right="0"/>
<constraints>
<grid row="1" column="0" row-span="1" col-span="1" vsize-policy="3" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false">
<minimum-size width="760" height="230"/>
<preferred-size width="760" height="230"/>
<maximum-size width="760" height="230"/>
</grid>
</constraints>
<properties/>
<border type="line" title="Console log"/>
<children>
<scrollpane id="ca338" binding="consoleScrollContainer">
<constraints>
<grid row="0" column="0" row-span="1" col-span="1" vsize-policy="7" hsize-policy="7" anchor="0" fill="3" indent="0" use-parent-layout="false">
<minimum-size width="740" height="200"/>
<preferred-size width="740" height="200"/>
<maximum-size width="740" height="200"/>
</grid>
</constraints>
<properties/>
<border type="none"/>
<children>
<component id="f5a07" class="javax.swing.JTextPane" binding="consoleArea">
<constraints/>
<properties/>
</component>
</children>
</scrollpane>
</children>
</grid>
<grid id="a1dd1" binding="interfaceContainer" layout-manager="BorderLayout" hgap="0" vgap="0">
<constraints>
<grid row="0" column="0" row-span="1" col-span="1" vsize-policy="3" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false">
<minimum-size width="760" height="300"/>
<preferred-size width="760" height="300"/>
<maximum-size width="760" height="300"/>
</grid>
</constraints>
<properties/>
<border type="none"/>
<children>
<grid id="7e8db" binding="directoryContainer" layout-manager="FlowLayout" hgap="20" vgap="5" flow-align="1">
<constraints border-constraint="North"/>
<properties>
<maximumSize width="760" height="50"/>
<minimumSize width="760" height="50"/>
<preferredSize width="760" height="50"/>
</properties>
<border type="none"/>
<children>
<component id="eb3ed" class="javax.swing.JTextField" binding="directoryField">
<constraints/>
<properties>
<maximumSize width="600" height="24"/>
<minimumSize width="600" height="24"/>
<preferredSize width="600" height="24"/>
<toolTipText value="A directory path where the process will be done"/>
</properties>
</component>
<component id="a1f19" class="javax.swing.JButton" binding="directoryButton">
<constraints/>
<properties>
<text value="Select directory"/>
</properties>
</component>
</children>
</grid>
<grid id="9bd00" binding="optionsContainer" layout-manager="BorderLayout" hgap="0" vgap="0">
<constraints border-constraint="Center"/>
<properties>
<maximumSize width="760" height="90"/>
<minimumSize width="760" height="90"/>
<preferredSize width="760" height="90"/>
</properties>
<border type="line" title="Options"/>
<children>
<component id="2f2b1" class="javax.swing.JCheckBox" binding="endTrimCheckbox">
<constraints border-constraint="North"/>
<properties>
<horizontalAlignment value="0"/>
<text value="Remove trailing spaces/tabs"/>
</properties>
</component>
<component id="5da45" class="javax.swing.JCheckBox" binding="emptyLineCheckBox">
<constraints border-constraint="Center"/>
<properties>
<horizontalAlignment value="0"/>
<text value="Remove empty lines"/>
</properties>
</component>
<grid id="d154c" binding="fileFormatContainer" layout-manager="FlowLayout" hgap="5" vgap="5" flow-align="1">
<constraints border-constraint="South"/>
<properties/>
<border type="none"/>
<children>
<component id="2bdad" class="javax.swing.JLabel" binding="fileFormatLabel">
<constraints/>
<properties>
<text value="File extensions separated by a comma (ex. java,cpp,lua):"/>
</properties>
</component>
<component id="38c41" class="javax.swing.JTextField" binding="fileFormatField">
<constraints/>
<properties>
<maximumSize width="440" height="24"/>
<minimumSize width="440" height="24"/>
<preferredSize width="440" height="24"/>
<toolTipText value="Write the extensions separated with a comma. For example: java,cpp,lua"/>
</properties>
</component>
</children>
</grid>
</children>
</grid>
<grid id="5e126" binding="utilityContainer" layout-manager="BorderLayout" hgap="0" vgap="0">
<constraints border-constraint="South"/>
<properties>
<maximumSize width="760" height="110"/>
<minimumSize width="760" height="110"/>
<preferredSize width="760" height="110"/>
</properties>
<border type="none"/>
<children>
<grid id="4ff25" binding="processContainer" layout-manager="FlowLayout" hgap="5" vgap="5" flow-align="1">
<constraints border-constraint="North"/>
<properties/>
<border type="none"/>
<children>
<component id="6af10" class="javax.swing.JButton" binding="processButton">
<constraints/>
<properties>
<text value="Process!"/>
</properties>
</component>
</children>
</grid>
<grid id="3a52b" binding="progressContainer" layout-manager="FlowLayout" hgap="5" vgap="5" flow-align="1">
<constraints border-constraint="Center"/>
<properties>
<maximumSize width="715" height="80"/>
<minimumSize width="715" height="80"/>
<preferredSize width="715" height="80"/>
</properties>
<border type="none"/>
<children>
<grid id="cb18d" binding="statusContainer" layout-manager="BorderLayout" hgap="0" vgap="0">
<constraints/>
<properties>
<maximumSize width="200" height="60"/>
<minimumSize width="200" height="60"/>
<preferredSize width="200" height="60"/>
</properties>
<border type="none"/>
<children>
<component id="f94a5" class="javax.swing.JLabel" binding="statusLabel">
<constraints border-constraint="North"/>
<properties>
<focusable value="false"/>
<font name="Segoe UI" size="12" style="1"/>
<horizontalAlignment value="0"/>
<text value="Status: READY"/>
</properties>
</component>
<component id="40e9f" class="javax.swing.JLabel" binding="statusIcon">
<constraints border-constraint="South"/>
<properties>
<horizontalAlignment value="0"/>
<icon value="nl/dutchman/spacetrimmer/resources/ready.png"/>
<text value=""/>
</properties>
</component>
</children>
</grid>
<grid id="4ade3" layout-manager="BorderLayout" hgap="0" vgap="0">
<constraints/>
<properties>
<maximumSize width="500" height="60"/>
<minimumSize width="500" height="60"/>
<preferredSize width="500" height="60"/>
</properties>
<border type="none"/>
<children>
<component id="7e0d6" class="javax.swing.JLabel" binding="threadsLabel">
<constraints border-constraint="North"/>
<properties>
<horizontalAlignment value="0"/>
<text value="Currently idle. Awaiting for input"/>
</properties>
</component>
<component id="20f1" class="javax.swing.JLabel" binding="currentLabel">
<constraints border-constraint="South"/>
<properties>
<horizontalAlignment value="0"/>
<requestFocusEnabled value="false"/>
<text value="Processed 0,0 kB of 0,0 kB. Files processed: 0 out of 0"/>
</properties>
</component>
<component id="60f45" class="javax.swing.JProgressBar" binding="progressBar">
<constraints border-constraint="Center"/>
<properties>
<maximum value="100"/>
</properties>
</component>
</children>
</grid>
</children>
</grid>
</children>
</grid>
</children>
</grid>
</children>
</grid>
</form>
Loading

0 comments on commit 7d91aff

Please sign in to comment.